Meow Cheat Sheet

From WikiOD

Here is the cheatsheat of Meow and basic guide on how to use Meow

Typical settings[edit | edit source]

const cli = require('meow')(`
  Usage: appname [options]

  Options:
        --lang LANG    set the language

  Other options:
    -h, --help         show usage information
    -v, --version      print version info and exit
`, {
  string: ['lang'],
  boolean: ['help', 'version'],
  alias: { h: 'help', v: 'version' }
})

string and boolean lets meow/minimist know which flags expect arguments (string) and which don’t (boolean).

Using the result[edit | edit source]

cli.flags   // { lang: 'en' }
cli.input   // []

Yes, flags are automatically camelCased!

Lesser-used settings[edit | edit source]

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.

Credit:rstacruz