{ "_id": "meow", "_rev": "128-81376db0c77255e64abbcb7e31ce9e96", "name": "meow", "time": { "modified": "2020-09-27T02:27:14.069Z", "created": "2013-01-24T03:46:08.917Z", "0.0.0": "2013-01-24T03:46:15.395Z", "1.0.0": "2014-10-12T14:29:21.941Z", "2.0.0": "2014-10-21T21:49:43.338Z", "2.1.0": "2015-01-08T09:25:01.893Z", "3.0.0": "2015-01-23T15:56:16.289Z", "3.1.0": "2015-02-26T04:57:36.384Z", "3.3.0": "2015-06-18T23:18:00.331Z", "3.4.0": "2015-10-03T16:49:46.630Z", "3.4.1": "2015-10-03T18:05:20.683Z", "3.4.2": "2015-10-07T06:51:39.741Z", "3.5.0": "2015-10-30T05:04:51.853Z", "3.6.0": "2015-11-15T12:55:03.287Z", "3.7.0": "2016-01-04T14:20:49.240Z", "4.0.0": "2017-11-26T10:49:43.309Z", "4.0.1": "2018-04-25T03:05:56.651Z", "5.0.0": "2018-04-25T03:22:50.133Z", "6.0.0": "2019-12-07T14:55:05.771Z", "6.0.1": "2020-02-14T18:25:50.016Z", "6.1.0": "2020-03-19T17:58:18.280Z", "6.1.1": "2020-05-02T10:02:36.697Z", "7.0.0": "2020-05-07T05:49:56.632Z", "7.0.1": "2020-05-11T13:58:13.246Z", "7.1.0": "2020-08-10T20:29:43.861Z", "7.1.1": "2020-08-29T09:27:16.605Z" }, "maintainers": [ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], "dist-tags": { "latest": "7.1.1" }, "description": "CLI app helper", "readme": "# meow [](https://travis-ci.org/sindresorhus/meow)\n\n> CLI app helper\n\n\n\n## Features\n\n- Parses arguments\n- Converts flags to [camelCase](https://github.com/sindresorhus/camelcase)\n- Negates flags when using the `--no-` prefix\n- Outputs version when `--version`\n- Outputs description and supplied help text when `--help`\n- Makes unhandled rejected promises [fail hard](https://github.com/sindresorhus/hard-rejection) instead of the default silent fail\n- Sets the process title to the binary name defined in package.json\n\n## Install\n\n```\n$ npm install meow\n```\n\n## Usage\n\n```\n$ ./foo-app.js unicorns --rainbow\n```\n\n**CommonJS**\n\n```js\n#!/usr/bin/env node\n'use strict';\nconst meow = require('meow');\nconst foo = require('.');\n\nconst cli = meow(`\n\tUsage\n\t $ foo \n\n\tOptions\n\t --rainbow, -r Include a rainbow\n\n\tExamples\n\t $ foo unicorns --rainbow\n\t 🌈 unicorns 🌈\n`, {\n\tflags: {\n\t\trainbow: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'r'\n\t\t}\n\t}\n});\n/*\n{\n\tinput: ['unicorns'],\n\tflags: {rainbow: true},\n\t...\n}\n*/\n\nfoo(cli.input[0], cli.flags);\n```\n\n**ES Modules**\n\n```js\n#!/usr/bin/env node\nimport {createRequire} from 'module';\nimport foo from './lib/index.js';\n\nconst meow = createRequire(import.meta.url)('meow');\n\nconst cli = meow(`\n\tUsage\n\t $ foo \n\n\tOptions\n\t --rainbow, -r Include a rainbow\n\n\tExamples\n\t $ foo unicorns --rainbow\n\t 🌈 unicorns 🌈\n`, {\n\tflags: {\n\t\trainbow: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'r'\n\t\t}\n\t}\n});\n/*\n{\n\tinput: ['unicorns'],\n\tflags: {rainbow: true},\n\t...\n}\n*/\n\nfoo(cli.input[0], cli.flags);\n```\n\n## API\n\n### meow(helpText, options?)\n### meow(options)\n\nReturns an `object` with:\n\n- `input` *(Array)* - Non-flag arguments\n- `flags` *(Object)* - Flags converted to camelCase excluding aliases\n- `unnormalizedFlags` *(Object)* - Flags converted to camelCase including aliases\n- `pkg` *(Object)* - The `package.json` object\n- `help` *(string)* - The help text used with `--help`\n- `showHelp([exitCode=2])` *(Function)* - Show the help text and exit with `exitCode`\n- `showVersion()` *(Function)* - Show the version text and exit\n\n#### helpText\n\nType: `string`\n\nShortcut for the `help` option.\n\n#### options\n\nType: `object`\n\n##### flags\n\nType: `object`\n\nDefine argument flags.\n\nThe key is the flag name and the value is an object with any of:\n\n- `type`: Type of value. (Possible values: `string` `boolean` `number`)\n- `alias`: Usually used to define a short flag alias.\n- `default`: Default value when the flag is not specified.\n- `isRequired`: Determine if the flag is required. (Default: false)\n\t- If it's only known at runtime whether the flag is required or not, you can pass a `Function` instead of a `boolean`, which based on the given flags and other non-flag arguments, should decide if the flag is required. Two arguments are passed to the function:\n\t- The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.\n\t- The second argument is the **input** string array, which contains the non-flag arguments.\n\t- The function should return a `boolean`, true if the flag is required, otherwise false.\n- `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)\n\nExample:\n\n```js\nflags: {\n\tunicorn: {\n\t\ttype: 'string',\n\t\talias: 'u',\n\t\tdefault: ['rainbow', 'cat'],\n\t\tisMultiple: true,\n\t\tisRequired: (flags, input) => {\n\t\t\tif (flags.otherFlag) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\t}\n}\n```\n\n##### description\n\nType: `string | boolean`\\\nDefault: The package.json `\"description\"` property\n\nDescription to show above the help text.\n\nSet it to `false` to disable it altogether.\n\n##### help\n\nType: `string | boolean`\n\nThe help text you want shown.\n\nThe input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.\n\nThe description will be shown above your help text automatically.\n\n##### version\n\nType: `string | boolean`\\\nDefault: The package.json `\"version\"` property\n\nSet a custom version output.\n\n##### autoHelp\n\nType: `boolean`\\\nDefault: `true`\n\nAutomatically show the help text when the `--help` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own help text.\n\nThis option is only considered when there is only one argument in `process.argv`.\n\n##### autoVersion\n\nType: `boolean`\\\nDefault: `true`\n\nAutomatically show the version text when the `--version` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own version text.\n\n This option is only considered when there is only one argument in `process.argv`.\n\n##### pkg\n\nType: `object`\\\nDefault: Closest package.json upwards\n\npackage.json as an `object`.\n\n*You most likely don't need this option.*\n\n##### argv\n\nType: `string[]`\\\nDefault: `process.argv.slice(2)`\n\nCustom arguments object.\n\n##### inferType\n\nType: `boolean`\\\nDefault: `false`\n\nInfer the argument type.\n\nBy default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.\n\n##### booleanDefault\n\nType: `boolean | null | undefined`\\\nDefault: `false`\n\nValue of `boolean` flags not defined in `argv`.\nIf set to `undefined` the flags not defined in `argv` will be excluded from the result.\nThe `default` value set in `boolean` flags take precedence over `booleanDefault`.\n\nExample:\n\n```js\nconst meow = require('meow');\n\nconst cli = meow(`\n\tUsage\n\t $ foo\n\n\tOptions\n\t --rainbow, -r Include a rainbow\n\t --unicorn, -u Include a unicorn\n\t --no-sparkles Exclude sparkles\n\n\tExamples\n\t $ foo\n\t 🌈 unicorns✨🌈\n`, {\n\tbooleanDefault: undefined,\n\tflags: {\n\t\trainbow: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: true,\n\t\t\talias: 'r'\n\t\t},\n\t\tunicorn: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\talias: 'u'\n\t\t},\n\t\tcake: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'c'\n\t\t},\n\t\tsparkles: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: true\n\t\t}\n\t}\n});\n/*\n{\n\tflags: {\n\t\trainbow: true,\n\t\tunicorn: false,\n\t\tsparkles: true\n\t},\n\tunnormalizedFlags: {\n\t\trainbow: true,\n\t\tr: true,\n\t\tunicorn: false,\n\t\tu: false,\n\t\tsparkles: true\n\t},\n\t…\n}\n*/\n```\n\n##### hardRejection\n\nType: `boolean`\\\nDefault: `true`\n\nWhether to use [`hard-rejection`](https://github.com/sindresorhus/hard-rejection) or not. Disabling this can be useful if you need to handle `process.on('unhandledRejection')` yourself.\n\n## Promises\n\nMeow will make unhandled rejected promises [fail hard](https://github.com/sindresorhus/hard-rejection) instead of the default silent fail. Meaning you don't have to manually `.catch()` promises used in your CLI.\n\n## Tips\n\nSee [`chalk`](https://github.com/chalk/chalk) if you want to colorize the terminal output.\n\nSee [`get-stdin`](https://github.com/sindresorhus/get-stdin) if you want to accept input from stdin.\n\nSee [`conf`](https://github.com/sindresorhus/conf) if you need to persist some data.\n\nSee [`update-notifier`](https://github.com/yeoman/update-notifier) if you want update notifications.\n\n[More useful CLI utilities…](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities)\n\n---\n\n