meow: update
This commit is contained in:
parent
157fa66931
commit
2e8c207943
50
meow.md
50
meow.md
|
@ -1,29 +1,59 @@
|
||||||
---
|
---
|
||||||
title: Meow
|
title: Meow
|
||||||
category: JavaScript libraries
|
category: JavaScript libraries
|
||||||
|
layout: 2017/sheet
|
||||||
|
updated: 2017-10-30
|
||||||
|
weight: -1
|
||||||
|
intro: |
|
||||||
|
[meow](https://npmjs.com/package/meow) is the easiest way to write command line apps for Node.js.
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### Typical settings
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const cli = require('meow')(`
|
const cli = require('meow')(`
|
||||||
Usage: appname [options]
|
Usage: appname [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help show usage information
|
--lang LANG set the language
|
||||||
-v, --version print version info and exit
|
|
||||||
|
Other options:
|
||||||
|
-h, --help show usage information
|
||||||
|
-v, --version print version info and exit
|
||||||
`, {
|
`, {
|
||||||
alias: { h: 'help', v: 'version', x: 'excludeTag' },
|
|
||||||
string: ['lang'],
|
string: ['lang'],
|
||||||
boolean: ['pager'],
|
boolean: ['help', 'version'],
|
||||||
default: { lang: 'en' },
|
alias: { h: 'help', v: 'version' }
|
||||||
'--': true,
|
|
||||||
stopEarly: true, /* populate _ with first non-option */
|
|
||||||
unknown: function () { ... } /* invoked on unknown param */
|
|
||||||
})
|
})
|
||||||
|
```
|
||||||
|
|
||||||
cli.flags // { excludeTag: true }
|
`string` and `boolean` lets meow/minimist know which flags expect arguments (`string`) and which don't (`boolean`).
|
||||||
|
|
||||||
|
### Using the result
|
||||||
|
|
||||||
|
```js
|
||||||
|
cli.flags // { lang: 'en' }
|
||||||
cli.input // []
|
cli.input // []
|
||||||
|
```
|
||||||
|
|
||||||
// yes, flags are camelCased
|
Yes, flags are automatically camelCased!
|
||||||
|
|
||||||
|
### Lesser-used settings
|
||||||
|
|
||||||
|
```js
|
||||||
|
meow(`...`, {
|
||||||
|
// Default values if flags are not specified
|
||||||
|
default: { lang: 'en' },
|
||||||
|
|
||||||
|
// allow using -- to stop processing flags
|
||||||
|
'--': true,
|
||||||
|
|
||||||
|
// Populate `_` with first non-option
|
||||||
|
stopEarly: true,
|
||||||
|
|
||||||
|
// Invoked on unknown param
|
||||||
|
unknown: function () { ... }
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Also see [minimist](minimist.html).
|
Also see [minimist](minimist.html).
|
||||||
|
|
Loading…
Reference in New Issue