{"name":"meow","version":"14.1.0","description":"CLI app helper","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/meow.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./build/index.d.ts","default":"./build/index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"prepare":"npm run build","build":"rollup --config","test":"xo && npm run build && ava && tsd --typings build/index.d.ts"},"keywords":["cli","bin","util","utility","helper","argv","command","line","meow","cat","kitten","parser","option","flags","input","cmd","console"],"devDependencies":{"@rollup/plugin-commonjs":"^29.0.0","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^16.0.3","@sindresorhus/tsconfig":"^8.1.0","@types/minimist":"^1.2.5","ava":"^6.4.1","camelcase-keys":"^10.0.2","common-tags":"^2.0.0-alpha.1","decamelize":"^6.0.1","decamelize-keys":"^2.0.1","delete_comments":"^0.0.2","execa":"^9.6.1","globby":"^16.1.1","indent-string":"^5.0.0","minimist-options":"4.1.0","normalize-package-data":"^8.0.0","read-package-up":"^12.0.0","read-pkg":"^10.1.0","redent":"^4.0.0","rollup":"^4.57.1","rollup-plugin-dts":"^6.3.0","rollup-plugin-license":"^3.7.0","stack-utils":"^2.0.6","trim-newlines":"^5.0.0","tsd":"^0.33.0","type-fest":"^5.4.4","typescript":"~5.9.3","xo":"^1.2.3","yargs-parser":"^22.0.0"},"xo":{"rules":{"unicorn/no-process-exit":"off","unicorn/error-message":"off","@typescript-eslint/no-unsafe-call":"off"},"ignores":["build"]},"gitHead":"14a216feea8408d84162fab5f9823c4d5b308ef2","_id":"meow@14.1.0","bugs":{"url":"https://github.com/sindresorhus/meow/issues"},"homepage":"https://github.com/sindresorhus/meow#readme","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-EDYo6VlmtnumlcBCbh1gLJ//9jvM/ndXHfVXIFrZVr6fGcwTUyCTFNTLCKuY3ffbK8L/+3Mzqnd58RojiZqHVw==","shasum":"3cd2d16ad534829ab12fcb5010fc2fdb89facd31","tarball":"http://registry-npm.ywwl.com/meow/download/meow-14.1.0.tgz","fileCount":11,"unpackedSize":410886,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD+q0CApj9wSHDNzGJjzj3wazd99YuP3fcbiD/eyk0kGgIgGeXcEKCJhl30qbWam3t1m0LVgRbjJ6j63qTkwR6wW0k="}],"size":92457,"noattachment":false,"key":"/meow/-/meow-14.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/meow_14.1.0_1771583443710_0.6531871689524469"},"_hasShrinkwrap":false,"readme":"# meow\n\n> CLI app helper\n\n![](meow.gif)\n\n*I would recommend reading this [guide](https://clig.dev) on how to make user-friendly command-line tools.*\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- Sets the process title to the binary name defined in package.json\n- No dependencies!\n\n## Install\n\n```sh\nnpm install meow\n```\n\n## Usage\n\n```sh\n./foo-app.js unicorns --rainbow\n```\n\n```js\n#!/usr/bin/env node\nimport meow from 'meow';\nimport foo from './lib/index.js';\n\nconst cli = meow(`\n\tUsage\n\t  $ foo <input>\n\n\tOptions\n\t  --rainbow, -r  Include a rainbow\n\n\tExamples\n\t  $ foo unicorns --rainbow\n\t  🌈 unicorns 🌈\n`, {\n\timportMeta: import.meta, // This is required\n\tflags: {\n\t\trainbow: {\n\t\t\ttype: 'boolean',\n\t\t\tshortFlag: 'r'\n\t\t}\n\t}\n});\n/*\n{\n\tinput: ['unicorns'],\n\tflags: {rainbow: true},\n\t...\n}\n*/\n\nfoo(cli.input.at(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- `command` *(string | undefined)* - The selected command when using `commands`\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##### importMeta\n\n**Required**\\\nType: `object`\n\nPass in [`import.meta`](https://nodejs.org/dist/latest/docs/api/esm.html#esm_import_meta). This is used to find the correct package.json file.\n\n##### input\n\nType: `object | string`\n\nOptions for non-flag input arguments.\n\nThe value is an object with any of:\n\n- `type`: Type of value. (Possible values: `string` `boolean` `number` `array` `string-array` `boolean-array` `number-array`)\n- `isRequired`: Determine if at least one non-flag input argument is required. (Default: false)\n\t- If it's only known at runtime whether the input is required or not, you can pass a `Function` instead of a `boolean`, which based on the given input should decide if the input is required.\n\t- The first argument is the **input** string array, which contains the non-flag arguments.\n\t- The function should return a `boolean`, true if the input is required, otherwise false.\n\nExample:\n\n```js\ninput: 'number'\n```\n\nExample:\n\n```js\ninput: {\n\tisRequired: true\n}\n```\n\n##### commands\n\nType: `string[]`\n\nList of valid commands. Commands must be a single argument without whitespace and must not start with `-`.\n\nWhen set, parsing stops at the first non-flag argument and treats it as the command. The remaining arguments are returned in `input` so they can be passed to a subcommand parser. An unknown command will show help and exit with code 2. Parent flags must appear before the command.\n\nIf no command is given, `cli.command` is `undefined` and meow does not exit — you decide what to do:\n\n```js\nif (!cli.command) {\n\tcli.showHelp(); // or showHelp(0), or a custom message, or a default command\n}\n```\n\nExample:\n\n```js\nimport meow from 'meow';\n\nconst cli = meow({\n\timportMeta: import.meta,\n\tcommands: ['run', 'list'],\n\tflags: {\n\t\tverbose: {\n\t\t\ttype: 'boolean',\n\t\t\tshortFlag: 'v'\n\t\t}\n\t}\n});\n\nif (!cli.command) {\n\tcli.showHelp(0);\n}\n\nif (cli.command === 'run') {\n\tconst runCli = meow({importMeta: import.meta, argv: cli.input});\n}\n```\n\n##### flags\n\nType: `object`\n\nDefine argument flags.\n\nThe key is the flag name in camel-case and the value is an object with any of:\n\n- `type`: Type of value. (Possible values: `string` `boolean` `number`)\n- `choices`: Limit valid values to a predefined set of choices.\n- `default`: Default value when the flag is not specified.\n- `shortFlag`: A short flag alias.\n- `aliases`: Other names for the flag.\n- `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)\n\t- Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values are [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).\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\nNote that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`).\n\nExample:\n\n```js\nflags: {\n\tunicorn: {\n\t\ttype: 'string',\n\t\tchoices: ['rainbow', 'cat', 'unicorn'],\n\t\tdefault: ['rainbow', 'cat'],\n\t\tshortFlag: 'u',\n\t\taliases: ['unicorns'],\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 | false`\\\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 | false`\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\nSet it to `false` to disable it altogether.\n\n##### version\n\nType: `string`\\\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 is only triggered when `--help` is the only argument.\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\nThis is only triggered when `--version` is the only argument.\n\n##### pkg\n\nType: `object`\\\nDefault: Closest package.json upwards\n\npackage.json as an `object`.\n\nNote: Setting this stops `meow` from finding a package.json.\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\nAlso applies to flags without explicit types. By default, `--count 42` remains as the string `'42'`. With `inferType: true`, it becomes the number `42`.\n\n##### booleanDefault\n\nType: `boolean | undefined`\\\nDefault: `false`\n\nValue of `boolean` flags not defined in `argv`.\n\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\n_Note: If used in conjunction with `isMultiple`, the default flag value is set to `[]`._\n\n__Caution: Explicitly specifying `undefined` for `booleanDefault` has different meaning from omitting key itself.__\n\nExample:\n\n```js\nimport meow from '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\timportMeta: import.meta,\n\tbooleanDefault: undefined,\n\tflags: {\n\t\trainbow: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: true,\n\t\t\tshortFlag: 'r'\n\t\t},\n\t\tunicorn: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\tshortFlag: 'u'\n\t\t},\n\t\tcake: {\n\t\t\ttype: 'boolean',\n\t\t\tshortFlag: '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##### allowUnknownFlags\n\nType: `boolean`\\\nDefault: `true`\n\nWhether to allow unknown flags or not.\n\n> [!NOTE]\n> Flags declared in camelCase accept both `--camelCase` and `--camel-case` (including when `allowUnknownFlags` is `false`).\n\n##### helpIndent\n\nType: `number`\\\nDefault: `2`\n\nThe number of spaces to use for indenting the help text.\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\n[More useful CLI utilities…](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities)\n","publish_time":1771583443850,"_cnpm_publish_time":1771583443850,"dist-tags":{"latest":"14.1.0"}}