From 2e8c207943bd38bd5ac57aa0085ff1f7386c1d76 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Mon, 30 Oct 2017 00:25:02 +0800 Subject: [PATCH] meow: update --- meow.md | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/meow.md b/meow.md index 512a357d3..c5f3c03e4 100644 --- a/meow.md +++ b/meow.md @@ -1,29 +1,59 @@ --- title: Meow 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 const cli = require('meow')(` Usage: appname [options] Options: - -h, --help show usage information - -v, --version print version info and exit + --lang LANG set the language + + Other options: + -h, --help show usage information + -v, --version print version info and exit `, { - alias: { h: 'help', v: 'version', x: 'excludeTag' }, string: ['lang'], - boolean: ['pager'], - default: { lang: 'en' }, - '--': true, - stopEarly: true, /* populate _ with first non-option */ - unknown: function () { ... } /* invoked on unknown param */ + boolean: ['help', 'version'], + alias: { h: 'help', v: 'version' } }) +``` -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 // [] +``` -// 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).