meow-shorts

Additional shortcuts for meow... Meow!

Usage no npm install needed!

<script type="module">
  import meowShorts from 'https://cdn.skypack.dev/meow-shorts';
</script>

README

meow-shorts

License XO code style

This library is a wrapper for the faboulous meow that enables a few shortcuts:

  • -h for --help
  • -v for --version

Basically this library calls showHelp() and showVersion() when the command arguments contain either '-h' or '-v' respectively.

This is a module built ad-hoc for meow, so this is the reason why meow is a peer dependency for this project.

Install

npm

$ npm install meow meow-shorts

yarn

$ yarn add meow meow-shorts

Usage

#!/usr/bin/env node

const meow = require('meow');
const meowShorts = require('meow-shorts');

const cli = meow(`
    Usage
      $ foo <input>

    Options
      --rainbow, -r  Include a rainbow

    Examples
      $ foo unicorns --rainbow
      🌈 unicorns 🌈
`, {
    flags: {
        rainbow: {
            type: 'boolean',
            alias: 'r'
        }
    }
});

meowShorts(cli);

// Regular usage

API

meowShorts(cli, [options])

Wraps the object returned handling help and version shortcuts.

cli

Type: meow.Result

The object returned from meow(...) invocation.

options

Type: Object

enableHelpShortcut

Type: boolean
Default: true

Explicitly disable the '-h' shortcut to the 'help' command.

enableVersionShortcut

Type: boolean
Default: true

Explicitly disable the '-v' shortcut to the 'version' command.

helpShortcutExitCode

Type: number
Default: undefined

Set a custom exit code for the 'help' command. If you don't override this, this module reverts to the default meow exit code (which is 2).

License

MIT © Nicola Dal Maso