From 539d968ad76f18facb8baa5636bcbee46bd76ca4 Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Mon, 31 May 2021 11:14:03 -0700 Subject: [PATCH] Use commander preAction hook for setMode Hooks are new to commander v8. We can use hooks to ensure that `setMode` is called before every command is invoked. --- lib/runner.js | 8 +- lib/runner.js.map | 2 +- node_modules/.package-lock.json | 8 +- node_modules/commander/CHANGELOG.md | 441 +++-- node_modules/commander/Readme.md | 671 ++++--- node_modules/commander/esm.mjs | 15 + node_modules/commander/index.js | 1839 +------------------ node_modules/commander/lib/argument.js | 131 ++ node_modules/commander/lib/command.js | 1810 ++++++++++++++++++ node_modules/commander/lib/error.js | 45 + node_modules/commander/lib/help.js | 392 ++++ node_modules/commander/lib/option.js | 194 ++ node_modules/commander/package-support.json | 16 + node_modules/commander/package.json | 57 +- node_modules/commander/typings/index.d.ts | 1086 +++++++---- package-lock.json | 16 +- package.json | 2 +- src/runner.ts | 9 +- 18 files changed, 4066 insertions(+), 2676 deletions(-) create mode 100644 node_modules/commander/esm.mjs create mode 100644 node_modules/commander/lib/argument.js create mode 100644 node_modules/commander/lib/command.js create mode 100644 node_modules/commander/lib/error.js create mode 100644 node_modules/commander/lib/help.js create mode 100644 node_modules/commander/lib/option.js create mode 100644 node_modules/commander/package-support.json diff --git a/lib/runner.js b/lib/runner.js index 08227a76b9..a17ed2cf8d 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -25,7 +25,9 @@ const util_1 = require("./util"); // eslint-disable-next-line import/no-commonjs const pkg = require("../package.json"); const program = new commander_1.Command(); -program.version(pkg.version); +program.version(pkg.version).hook("preAction", () => { + actions_util_1.setMode(actions_util_1.Mode.runner); +}); function getTempDir(userInput) { const tempDir = path.join(userInput || process.cwd(), "codeql-runner"); if (!fs.existsSync(tempDir)) { @@ -98,7 +100,6 @@ program .option("--trace-process-name ", "(Advanced, windows-only) Inject a windows tracer of this process into a process with the given process name.") .option("--trace-process-level ", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process levels up.") .action(async (cmd) => { - actions_util_1.setMode(actions_util_1.Mode.runner); const logger = logging_1.getRunnerLogger(cmd.debug); try { const tempDir = getTempDir(cmd.tempDir); @@ -175,7 +176,6 @@ program .option("--temp-dir ", 'Directory to use for temporary files. Default is "./codeql-runner".') .option("--debug", "Print more verbose output", false) .action(async (cmd) => { - actions_util_1.setMode(actions_util_1.Mode.runner); const logger = logging_1.getRunnerLogger(cmd.debug); try { const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger); @@ -225,7 +225,6 @@ program .option("--category ", "String used by Code Scanning for matching the analyses.") .option("--debug", "Print more verbose output", false) .action(async (cmd) => { - actions_util_1.setMode(actions_util_1.Mode.runner); const logger = logging_1.getRunnerLogger(cmd.debug); try { const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger); @@ -266,7 +265,6 @@ program .option("--category ", "String used by Code Scanning for matching the analyses.") .option("--debug", "Print more verbose output", false) .action(async (cmd) => { - actions_util_1.setMode(actions_util_1.Mode.runner); const logger = logging_1.getRunnerLogger(cmd.debug); const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin); const apiDetails = { diff --git a/lib/runner.js.map b/lib/runner.js.map index 43c515fcfb..1fabdacf96 100644 --- a/lib/runner.js.map +++ b/lib/runner.js.map @@ -1 +1 @@ -{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,yCAAoC;AAEpC,iDAA+C;AAC/C,uCAAuC;AACvC,2CAAuE;AACvE,qCAA6C;AAC7C,iDAAmD;AACnD,iCAA8E;AAC9E,2CAAsD;AACtD,uCAA4C;AAC5C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAQgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvC,MAAM,OAAO,GAAG,IAAI,mBAAO,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EACtB,+HAA+H,CAChI;KACA,MAAM,CACL,qBAAqB,EACrB,6DAA6D,CAC9D;KACA,MAAM,CACL,wBAAwB,EACxB,0DAA0D,CAC3D;KACA,MAAM,CACL,uBAAuB,EACvB,yDAAyD,CAC1D;KACA,MAAM,CAAC,SAAS,EAAE,2BAA2B,EAAE,KAAK,CAAC;KACrD,MAAM,CAAC,KAAK,EAAE,GAAe,EAAE,EAAE;IAChC,MAAM,MAAM,GAAG,yBAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,MAAM,oBAAa,CAC9B,MAAM,EACN,GAAG,CAAC,UAAU,EACd,GAAG,CAAC,eAAe,CACpB,CAAC;IACF,MAAM,UAAU,GAAG;QACjB,IAAI;QACJ,GAAG,EAAE,qBAAc,CAAC,GAAG,CAAC,SAAS,CAAC;KACnC,CAAC;IACF,IAAI;QACF,MAAM,aAAa,GAAG,MAAM,uBAAgB,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,UAAU,CAAC,gBAAgB,CAC/B,GAAG,CAAC,SAAS,EACb,+BAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EAClC,GAAG,CAAC,MAAM,EACV,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EACjB,GAAG,CAAC,QAAQ,EACZ,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,EACjC,aAAa,EACb,UAAU,EACV,MAAM,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index a919ad4902..d70ac71b43 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1429,11 +1429,11 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "node_modules/commander": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-6.0.0.tgz", - "integrity": "sha512-s7EA+hDtTYNhuXkTlhqew4txMZVdszBmKWSPEMxGr8ru8JXR7bLUFIAtPhcSuFdJQ0ILMxnJi8GkQL0yvDy/YA==", + "version": "8.0.0-1", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.0.0-1.tgz", + "integrity": "sha512-tSrRWF7x0QOO7bjPJIWxOmFtrqcUGWkyp4zANM8ZholgD2gtw9zRNtM5RtbQyOQAu/qp01tnvyFmP8KrlXokHQ==", "engines": { - "node": ">= 6" + "node": ">= 12" } }, "node_modules/common-path-prefix": { diff --git a/node_modules/commander/CHANGELOG.md b/node_modules/commander/CHANGELOG.md index b976f4f77f..3bba7d94ed 100644 --- a/node_modules/commander/CHANGELOG.md +++ b/node_modules/commander/CHANGELOG.md @@ -3,298 +3,343 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [6.0.0] (2020-07-21) +## [8.0.0-1] (2021-05-30) ### Added -- add support for variadic options ([#1250]) -- allow options to be added with just a short flag ([#1256]) -- throw an error if there might be a clash between option name and a Command property, with advice on how to resolve ([#1275]) +- `.addArgument()` ([#1490]) +- `Argument` supports `.choices()` ([#1525]) +- client typing of `.opts()` return type using TypeScript generics ([#1539]) -### Fixed +### Changed -- Options which contain -no- in the middle of the option flag should not be treated as negatable. ([#1301]) +- refactor `index.tab` into a file per class ([#1522]) +- update dependencies -## [6.0.0-0] (2020-06-20) +## [8.0.0-0] (2021-05-23) -(Released in 6.0.0) +### Added -## [5.1.0] (2020-04-25) +- `.getOptionValue()` and `.setOptionValue()` ([#1521]) +- `.hook()` with support for `'preAction'` and `'postAction'` callbacks ([#1514]) +- `.argument(name, description)` for adding command-arguments ([#1490]) + - supports default value for optional command-arguments ([#1508]) + - supports custom processing function ([#1508]) +- `.createArgument()` factory method ([#1497]) +- the number of command-arguments is checked for programs without an action handler ([#1502]) -### Added +### Changed -- support for multiple command aliases, the first of which is shown in the auto-generated help ([#531], [#1236]) -- configuration support in `addCommand()` for `hidden` and `isDefault` ([#1232]) +- refactor and simplify TypeScript declarations (with no default export) ([#1520]) +- `.parseAsync()` is now declared as `async` ([#1513]) +- *Breaking:* `Help` method `.visibleArguments()` returns array of `Argument` ([#1490]) +- *Breaking:* Commander 8 requires Node.js 12 or higher ([#1500]) +- *Breaking:* `CommanderError` code `commander.invalidOptionArgument` renamed `commander.invalidArgument` ([#1508]) +- *Breaking:* TypeScript declaration for `.addTextHelp()` callback no longer allows result of `undefined`, now just `string` ([#1516]) -### Fixed +### Deprecated + +- second parameter of `cmd.description(desc, argDescriptions)` for adding argument descriptions ([#1490]) + - (use new `.argument(name, description)` instead) +- `InvalidOptionArgumentError` (replaced by `InvalidArgumentError`) ([#1508]) + +### Removed + +- *Breaking:* TypeScript declaration for default export of global `Command` object ([#1520]) + - (still available as named `program` export) -- omit masked help flags from the displayed help ([#645], [#1247]) -- remove old short help flag when change help flags using `helpOption` ([#1248]) +## [7.2.0] (2021-03-22) + +### Added + +- TypeScript typing for `parent` property on `Command` ([#1475]) +- TypeScript typing for `.attributeName()` on `Option` ([#1483]) +- support information in package ([#1477]) ### Changed -- remove use of `arguments` to improve auto-generated help in editors ([#1235]) -- rename `.command()` configuration `noHelp` to `hidden` (but not remove old support) ([#1232]) -- improvements to documentation +- improvements to error messages, README, and tests - update dependencies -- update tested versions of node -- eliminate lint errors in TypeScript ([#1208]) -## [5.0.0] (2020-03-14) +## [7.1.0] (2021-02-15) ### Added -* support for nested commands with action-handlers ([#1] [#764] [#1149]) -* `.addCommand()` for adding a separately configured command ([#764] [#1149]) -* allow a non-executable to be set as the default command ([#742] [#1149]) -* implicit help command when there are subcommands (previously only if executables) ([#1149]) -* customise implicit help command with `.addHelpCommand()` ([#1149]) -* display error message for unknown subcommand, by default ([#432] [#1088] [#1149]) -* display help for missing subcommand, by default ([#1088] [#1149]) -* combined short options as single argument may include boolean flags and value flag and value (e.g. `-a -b -p 80` can be written as `-abp80`) ([#1145]) -* `.parseOption()` includes short flag and long flag expansions ([#1145]) -* `.helpInformation()` returns help text as a string, previously a private routine ([#1169]) -* `.parse()` implicitly uses `process.argv` if arguments not specified ([#1172]) -* optionally specify where `.parse()` arguments "from", if not following node conventions ([#512] [#1172]) -* suggest help option along with unknown command error ([#1179]) -* TypeScript definition for `commands` property of `Command` ([#1184]) -* export `program` property ([#1195]) -* `createCommand` factory method to simplify subclassing ([#1191]) +- support for named imports from ECMAScript modules ([#1440]) +- add `.cjs` to list of expected script file extensions ([#1449]) +- allow using option choices and variadic together ([#1454]) ### Fixed -* preserve argument order in subcommands ([#508] [#962] [#1138]) -* do not emit `command:*` for executable subcommands ([#809] [#1149]) -* action handler called whether or not there are non-option arguments ([#1062] [#1149]) -* combining option short flag and value in single argument now works for subcommands ([#1145]) -* only add implicit help command when it will not conflict with other uses of argument ([#1153] [#1149]) -* implicit help command works with command aliases ([#948] [#1149]) -* options are validated whether or not there is an action handler ([#1149]) +- replace use of deprecated `process.mainModule` ([#1448]) +- regression for legacy `command('*')` and call when command line includes options ([#1464]) +- regression for `on('command:*', ...)` and call when command line includes unknown options ([#1464]) +- display best error for combination of unknown command and unknown option (i.e. unknown command) ([#1464]) ### Changed -* *Breaking* `.args` contains command arguments with just recognised options removed ([#1032] [#1138]) -* *Breaking* display error if required argument for command is missing ([#995] [#1149]) -* tighten TypeScript definition of custom option processing function passed to `.option()` ([#1119]) -* *Breaking* `.allowUnknownOption()` ([#802] [#1138]) - * unknown options included in arguments passed to command action handler - * unknown options included in `.args` -* only recognised option short flags and long flags are expanded (e.g. `-ab` or `--foo=bar`) ([#1145]) -* *Breaking* `.parseOptions()` ([#1138]) - * `args` in returned result renamed `operands` and does not include anything after first unknown option - * `unknown` in returned result has arguments after first unknown option including operands, not just options and values -* *Breaking* `.on('command:*', callback)` and other command events passed (changed) results from `.parseOptions`, i.e. operands and unknown ([#1138]) -* refactor Option from prototype to class ([#1133]) -* refactor Command from prototype to class ([#1159]) -* changes to error handling ([#1165]) - * throw for author error, not just display message - * preflight for variadic error - * add tips to missing subcommand executable -* TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180]) -* `.parseAsync` returns `Promise` to be consistent with `.parse()` ([#1180]) -* update dependencies +- make TypeScript typings tests stricter ([#1453]) +- improvements to README and tests -### Removed +## [7.0.0] (2021-01-15) -* removed EventEmitter from TypeScript definition for Command, eliminating implicit peer dependency on `@types/node` ([#1146]) -* removed private function `normalize` (the functionality has been integrated into `parseOptions`) ([#1145]) -* `parseExpectedArgs` is now private ([#1149]) +### Added -### Migration Tips +- `.enablePositionalOptions()` to let program and subcommand reuse same option ([#1427]) +- `.passThroughOptions()` to pass options through to other programs without needing `--` ([#1427]) +- `.allowExcessArguments(false)` to show an error message if there are too many command-arguments on command line for the action handler ([#1409]) +- `.configureOutput()` to modify use of stdout and stderr or customise display of errors ([#1387]) +- use `.addHelpText()` to add text before or after the built-in help, for just current command or also for all subcommands ([#1296]) +- enhance Option class ([#1331]) + - allow hiding options from help + - allow restricting option arguments to a list of choices + - allow setting how default value is shown in help +- `.createOption()` to support subclassing of automatically created options (like `.createCommand()`) ([#1380]) +- refactor the code generating the help into a separate public Help class ([#1365]) + - support sorting subcommands and options in help + - support specifying wrap width (columns) + - allow subclassing Help class + - allow configuring Help class without subclassing -If you use `.on('command:*')` or more complicated tests to detect an unrecognised subcommand, you may be able to delete the code and rely on the default behaviour. +### Changed -If you use `program.args` or more complicated tests to detect a missing subcommand, you may be able to delete the code and rely on the default behaviour. +- *Breaking:* options are stored safely by default, not as properties on the command ([#1409]) + - this especially affects accessing options on program, use `program.opts()` + - revert behaviour with `.storeOptionsAsProperties()` +- *Breaking:* action handlers are passed options and command separately ([#1409]) +- deprecated callback parameter to `.help()` and `.outputHelp()` (removed from README) ([#1296]) +- *Breaking:* errors now displayed using `process.stderr.write()` instead of `console.error()` +- deprecate `.on('--help')` (removed from README) ([#1296]) +- initialise the command description to empty string (previously undefined) ([#1365]) +- document and annotate deprecated routines ([#1349]) -If you use `.command('*')` to add a default command, you may be be able to switch to `isDefault:true` with a named command. +### Fixed -## [5.0.0-4] (2020-03-03) +- wrapping bugs in help ([#1365]) + - first line of command description was wrapping two characters early + - pad width calculation was not including help option and help command + - pad width calculation was including hidden options and commands +- improve backwards compatibility for custom command event listeners ([#1403]) + +### Deleted -(Released in 5.0.0) +- *Breaking:* `.passCommandToAction()` ([#1409]) + - no longer needed as action handler is passed options and command +- *Breaking:* "extra arguments" parameter to action handler ([#1409]) + - if being used to detect excess arguments, there is now an error available by setting `.allowExcessArguments(false)` -## [5.0.0-3] (2020-02-20) +### Migration Tips -(Released in 5.0.0) +The biggest change is the parsed option values. Previously the options were stored by default as properties on the command object, and now the options are stored separately. -## [5.0.0-2] (2020-02-10) +If you wish to restore the old behaviour and get running quickly you can call `.storeOptionsAsProperties()`. +To allow you to move to the new code patterns incrementally, the action handler will be passed the command _twice_, +to match the new "options" and "command" parameters (see below). -(Released in 5.0.0) +**program options** -## [5.0.0-1] (2020-02-08) +Use the `.opts()` method to access the options. This is available on any command but is used most with the program. -(Released in 5.0.0) +```js +program.option('-d, --debug'); +program.parse(); +// Old code before Commander 7 +if (program.debug) console.log(`Program name is ${program.name()}`); +``` -## [5.0.0-0] (2020-02-02) +```js +// New code +const options = program.opts(); +if (options.debug) console.log(`Program name is ${program.name()}`); +``` -(Released in 5.0.0) +**action handler** -## [4.1.1] (2020-02-02) +The action handler gets passed a parameter for each command-argument you declared. Previously by default the next parameter was the command object with the options as properties. Now the next two parameters are instead the options and the command. If you +only accessed the options there may be no code changes required. -### Fixed +```js +program + .command('compress ') + .option('-t, --trace') + // Old code before Commander 7 + .action((filename, cmd)) => { + if (cmd.trace) console.log(`Command name is ${cmd.name()}`); + }); +``` -* TypeScript definition for `.action()` should include Promise for async ([#1157]) +```js + // New code + .action((filename, options, command)) => { + if (options.trace) console.log(`Command name is ${command.name()}`); + }); +``` -## [4.1.0] (2020-01-06) +If you already set `.storeOptionsAsProperties(false)` you may still need to adjust your code. -### Added +```js +program + .command('compress ') + .storeOptionsAsProperties(false) + .option('-t, --trace') + // Old code before Commander 7 + .action((filename, command)) => { + if (command.opts().trace) console.log(`Command name is ${command.name()}`); + }); +``` -* two routines to change how option values are handled, and eliminate name clashes with command properties ([#933] [#1102]) - * see storeOptionsAsProperties and passCommandToAction in README -* `.parseAsync` to use instead of `.parse` if supply async action handlers ([#806] [#1118]) +```js + // New code + .action((filename, options, command)) => { + if (command.opts().trace) console.log(`Command name is ${command.name()}`); + }); +``` -### Fixed +## [7.0.0-2] (2020-12-14) -* Remove trailing blanks from wrapped help text ([#1096]) +(Released in 7.0.0) -### Changed +## [7.0.0-1] (2020-11-21) + +(Released in 7.0.0) -* update dependencies -* extend security coverage for Commander 2.x to 2020-02-03 -* improvements to README -* improvements to TypeScript definition documentation -* move old versions out of main CHANGELOG -* removed explicit use of `ts-node` in tests +## [7.0.0-0] (2020-10-25) -## [4.0.1] (2019-11-12) +(Released in 7.0.0) + +## [6.2.1] (2020-12-13) ### Fixed -* display help when requested, even if there are missing required options ([#1091]) +- some tests failed if directory path included a space ([1390]) -## [4.0.0] (2019-11-02) +## [6.2.0] (2020-10-25) ### Added -* automatically wrap and indent help descriptions for options and commands ([#1051]) -* `.exitOverride()` allows override of calls to `process.exit` for additional error handling and to keep program running ([#1040]) -* support for declaring required options with `.requiredOptions()` ([#1071]) -* GitHub Actions support ([#1027]) -* translation links in README +- added 'tsx' file extension for stand-alone executable subcommands ([#1368]) +- documented second parameter to `.description()` to describe command arguments ([#1353]) +- documentation of special cases with options taking varying numbers of option-arguments ([#1332]) +- documentation for terminology ([#1361]) + +### Fixed + +- add missing TypeScript definition for `.addHelpCommand()' ([#1375]) +- removed blank line after "Arguments:" in help, to match "Options:" and "Commands:" ([#1360]) ### Changed -* dev: switch tests from Sinon+Should to Jest with major rewrite of tests ([#1035]) -* call default subcommand even when there are unknown options ([#1047]) -* *Breaking* Commander is only officially supported on Node 8 and above, and requires Node 6 ([#1053]) +- update dependencies -### Fixed +## [6.1.0] (2020-08-28) -* *Breaking* keep command object out of program.args when action handler called ([#1048]) - * also, action handler now passed array of unknown arguments -* complain about unknown options when program argument supplied and action handler ([#1049]) - * this changes parameters to `command:*` event to include unknown arguments -* removed deprecated `customFds` option from call to `child_process.spawn` ([#1052]) -* rework TypeScript declarations to bring all types into imported namespace ([#1081]) +### Added -### Migration Tips +- include URL to relevant section of README for error for potential conflict between Command properties and option values ([#1306]) +- `.combineFlagAndOptionalValue(false)` to ease upgrade path from older versions of Commander ([#1326]) +- allow disabling the built-in help option using `.helpOption(false)` ([#1325]) +- allow just some arguments in `argumentDescription` to `.description()` ([#1323]) -#### Testing for no arguments +### Changed -If you were previously using code like: +- tidy async test and remove lint override ([#1312]) -```js -if (!program.args.length) ... -``` +### Fixed -a partial replacement is: +- executable subcommand launching when script path not known ([#1322]) -```js -if (program.rawArgs.length < 3) ... -``` +## [6.0.0] (2020-07-21) + +### Added -## [4.0.0-1] Prerelease (2019-10-08) +- add support for variadic options ([#1250]) +- allow options to be added with just a short flag ([#1256]) + - *Breaking* the option property has same case as flag. e.g. flag `-n` accessed as `opts().n` (previously uppercase) +- *Breaking* throw an error if there might be a clash between option name and a Command property, with advice on how to resolve ([#1275]) + +### Fixed -(Released in 4.0.0) +- Options which contain -no- in the middle of the option flag should not be treated as negatable. ([#1301]) + +## [6.0.0-0] (2020-06-20) -## [4.0.0-0] Prerelease (2019-10-01) +(Released in 6.0.0) -(Released in 4.0.0) ## Older versions +* [5.x](./changelogs/CHANGELOG-5.md) +* [4.x](./changelogs/CHANGELOG-4.md) * [3.x](./changelogs/CHANGELOG-3.md) * [2.x](./changelogs/CHANGELOG-2.md) * [1.x](./changelogs/CHANGELOG-1.md) * [0.x](./changelogs/CHANGELOG-0.md) -[#1]: https://github.com/tj/commander.js/issues/1 -[#432]: https://github.com/tj/commander.js/issues/432 -[#508]: https://github.com/tj/commander.js/issues/508 -[#512]: https://github.com/tj/commander.js/issues/512 -[#531]: https://github.com/tj/commander.js/issues/531 -[#645]: https://github.com/tj/commander.js/issues/645 -[#742]: https://github.com/tj/commander.js/issues/742 -[#764]: https://github.com/tj/commander.js/issues/764 -[#802]: https://github.com/tj/commander.js/issues/802 -[#806]: https://github.com/tj/commander.js/issues/806 -[#809]: https://github.com/tj/commander.js/issues/809 [#948]: https://github.com/tj/commander.js/issues/948 -[#962]: https://github.com/tj/commander.js/issues/962 -[#995]: https://github.com/tj/commander.js/issues/995 -[#1027]: https://github.com/tj/commander.js/pull/1027 [#1032]: https://github.com/tj/commander.js/issues/1032 -[#1035]: https://github.com/tj/commander.js/pull/1035 -[#1040]: https://github.com/tj/commander.js/pull/1040 -[#1047]: https://github.com/tj/commander.js/pull/1047 -[#1048]: https://github.com/tj/commander.js/pull/1048 -[#1049]: https://github.com/tj/commander.js/pull/1049 -[#1051]: https://github.com/tj/commander.js/pull/1051 -[#1052]: https://github.com/tj/commander.js/pull/1052 -[#1053]: https://github.com/tj/commander.js/pull/1053 -[#1062]: https://github.com/tj/commander.js/pull/1062 -[#1071]: https://github.com/tj/commander.js/pull/1071 -[#1081]: https://github.com/tj/commander.js/pull/1081 -[#1088]: https://github.com/tj/commander.js/issues/1088 -[#1091]: https://github.com/tj/commander.js/pull/1091 -[#1096]: https://github.com/tj/commander.js/pull/1096 -[#1102]: https://github.com/tj/commander.js/pull/1102 -[#1118]: https://github.com/tj/commander.js/pull/1118 -[#1119]: https://github.com/tj/commander.js/pull/1119 -[#1133]: https://github.com/tj/commander.js/pull/1133 -[#1138]: https://github.com/tj/commander.js/pull/1138 -[#1145]: https://github.com/tj/commander.js/pull/1145 -[#1146]: https://github.com/tj/commander.js/pull/1146 -[#1149]: https://github.com/tj/commander.js/pull/1149 -[#1153]: https://github.com/tj/commander.js/issues/1153 -[#1157]: https://github.com/tj/commander.js/pull/1157 -[#1159]: https://github.com/tj/commander.js/pull/1159 -[#1165]: https://github.com/tj/commander.js/pull/1165 -[#1169]: https://github.com/tj/commander.js/pull/1169 -[#1172]: https://github.com/tj/commander.js/pull/1172 -[#1179]: https://github.com/tj/commander.js/pull/1179 -[#1180]: https://github.com/tj/commander.js/pull/1180 -[#1184]: https://github.com/tj/commander.js/pull/1184 -[#1191]: https://github.com/tj/commander.js/pull/1191 -[#1195]: https://github.com/tj/commander.js/pull/1195 -[#1208]: https://github.com/tj/commander.js/pull/1208 -[#1232]: https://github.com/tj/commander.js/pull/1232 -[#1235]: https://github.com/tj/commander.js/pull/1235 -[#1236]: https://github.com/tj/commander.js/pull/1236 -[#1247]: https://github.com/tj/commander.js/pull/1247 -[#1248]: https://github.com/tj/commander.js/pull/1248 [#1250]: https://github.com/tj/commander.js/pull/1250 [#1256]: https://github.com/tj/commander.js/pull/1256 [#1275]: https://github.com/tj/commander.js/pull/1275 +[#1296]: https://github.com/tj/commander.js/pull/1296 [#1301]: https://github.com/tj/commander.js/issues/1301 +[#1306]: https://github.com/tj/commander.js/pull/1306 +[#1312]: https://github.com/tj/commander.js/pull/1312 +[#1322]: https://github.com/tj/commander.js/pull/1322 +[#1323]: https://github.com/tj/commander.js/pull/1323 +[#1325]: https://github.com/tj/commander.js/pull/1325 +[#1326]: https://github.com/tj/commander.js/pull/1326 +[#1331]: https://github.com/tj/commander.js/pull/1331 +[#1332]: https://github.com/tj/commander.js/pull/1332 +[#1349]: https://github.com/tj/commander.js/pull/1349 +[#1353]: https://github.com/tj/commander.js/pull/1353 +[#1360]: https://github.com/tj/commander.js/pull/1360 +[#1361]: https://github.com/tj/commander.js/pull/1361 +[#1365]: https://github.com/tj/commander.js/pull/1365 +[#1368]: https://github.com/tj/commander.js/pull/1368 +[#1375]: https://github.com/tj/commander.js/pull/1375 +[#1380]: https://github.com/tj/commander.js/pull/1380 +[#1387]: https://github.com/tj/commander.js/pull/1387 +[#1390]: https://github.com/tj/commander.js/pull/1390 +[#1403]: https://github.com/tj/commander.js/pull/1403 +[#1409]: https://github.com/tj/commander.js/pull/1409 +[#1427]: https://github.com/tj/commander.js/pull/1427 +[#1440]: https://github.com/tj/commander.js/pull/1440 +[#1448]: https://github.com/tj/commander.js/pull/1448 +[#1449]: https://github.com/tj/commander.js/pull/1449 +[#1453]: https://github.com/tj/commander.js/pull/1453 +[#1454]: https://github.com/tj/commander.js/pull/1454 +[#1464]: https://github.com/tj/commander.js/pull/1464 +[#1475]: https://github.com/tj/commander.js/pull/1475 +[#1477]: https://github.com/tj/commander.js/pull/1477 +[#1483]: https://github.com/tj/commander.js/pull/1483 +[#1490]: https://github.com/tj/commander.js/pull/1490 +[#1497]: https://github.com/tj/commander.js/pull/1497 +[#1500]: https://github.com/tj/commander.js/pull/1500 +[#1508]: https://github.com/tj/commander.js/pull/1508 +[#1513]: https://github.com/tj/commander.js/pull/1513 +[#1514]: https://github.com/tj/commander.js/pull/1514 +[#1516]: https://github.com/tj/commander.js/pull/1516 +[#1520]: https://github.com/tj/commander.js/pull/1520 +[#1521]: https://github.com/tj/commander.js/pull/1521 +[#1522]: https://github.com/tj/commander.js/pull/1522 +[#1525]: https://github.com/tj/commander.js/pull/1525 +[#1539]: https://github.com/tj/commander.js/pull/1539 [Unreleased]: https://github.com/tj/commander.js/compare/master...develop +[8.0.0-0]: https://github.com/tj/commander.js/compare/v7.2.0...v8.0.0-0 +[7.2.0]: https://github.com/tj/commander.js/compare/v7.1.0...v7.2.0 +[7.1.0]: https://github.com/tj/commander.js/compare/v7.0.0...v7.1.0 +[7.0.0]: https://github.com/tj/commander.js/compare/v6.2.1...v7.0.0 +[7.0.0-2]: https://github.com/tj/commander.js/compare/v7.0.0-1...v7.0.0-2 +[7.0.0-1]: https://github.com/tj/commander.js/compare/v7.0.0-0...v7.0.0-1 +[7.0.0-0]: https://github.com/tj/commander.js/compare/v6.2.0...v7.0.0-0 +[6.2.1]: https://github.com/tj/commander.js/compare/v6.2.0..v6.2.1 +[6.2.0]: https://github.com/tj/commander.js/compare/v6.1.0..v6.2.0 +[6.1.0]: https://github.com/tj/commander.js/compare/v6.0.0..v6.1.0 [6.0.0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0 [6.0.0-0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0-0 -[5.1.0]: https://github.com/tj/commander.js/compare/v5.0.0..v5.1.0 -[5.0.0]: https://github.com/tj/commander.js/compare/v4.1.1..v5.0.0 -[5.0.0-4]: https://github.com/tj/commander.js/compare/v5.0.0-3..v5.0.0-4 -[5.0.0-3]: https://github.com/tj/commander.js/compare/v5.0.0-2..v5.0.0-3 -[5.0.0-2]: https://github.com/tj/commander.js/compare/v5.0.0-1..v5.0.0-2 -[5.0.0-1]: https://github.com/tj/commander.js/compare/v5.0.0-0..v5.0.0-1 -[5.0.0-0]: https://github.com/tj/commander.js/compare/v4.1.1..v5.0.0-0 -[4.1.1]: https://github.com/tj/commander.js/compare/v4.1.0..v4.1.1 -[4.1.0]: https://github.com/tj/commander.js/compare/v4.0.1..v4.1.0 -[4.0.1]: https://github.com/tj/commander.js/compare/v4.0.0..v4.0.1 -[4.0.0]: https://github.com/tj/commander.js/compare/v3.0.2..v4.0.0 -[4.0.0-1]: https://github.com/tj/commander.js/compare/v4.0.0-0..v4.0.0-1 -[4.0.0-0]: https://github.com/tj/commander.js/compare/v3.0.2...v4.0.0-0 diff --git a/node_modules/commander/Readme.md b/node_modules/commander/Readme.md index 577a163965..248bcf2d05 100644 --- a/node_modules/commander/Readme.md +++ b/node_modules/commander/Readme.md @@ -1,11 +1,11 @@ # Commander.js -[![Build Status](https://api.travis-ci.org/tj/commander.js.svg?branch=master)](http://travis-ci.org/tj/commander.js) +[![Build Status](https://github.com/tj/commander.js/workflows/build/badge.svg)](https://github.com/tj/commander.js/actions?query=workflow%3A%22build%22) [![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander) [![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://npmcharts.com/compare/commander?minimal=true) [![Install Size](https://packagephobia.now.sh/badge?p=commander)](https://packagephobia.now.sh/result?p=commander) -The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander). +The complete solution for [node.js](http://nodejs.org) command-line interfaces. Read this in other languages: English | [简体中文](./Readme_zh-CN.md) @@ -15,37 +15,43 @@ Read this in other languages: English | [简体中文](./Readme_zh-CN.md) - [Options](#options) - [Common option types, boolean and value](#common-option-types-boolean-and-value) - [Default option value](#default-option-value) - - [Other option types, negatable boolean and flag|value](#other-option-types-negatable-boolean-and-flagvalue) - - [Custom option processing](#custom-option-processing) + - [Other option types, negatable boolean and boolean|value](#other-option-types-negatable-boolean-and-booleanvalue) - [Required option](#required-option) - [Variadic option](#variadic-option) - [Version option](#version-option) + - [More configuration](#more-configuration) + - [Custom option processing](#custom-option-processing) - [Commands](#commands) - - [Specify the argument syntax](#specify-the-argument-syntax) - - [Action handler (sub)commands](#action-handler-subcommands) + - [Command-arguments](#command-arguments) + - [More configuration](#more-configuration-1) + - [Custom argument processing](#custom-argument-processing) + - [Action handler](#action-handler) - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands) + - [Life cycle hooks](#life-cycle-hooks) - [Automated help](#automated-help) - [Custom help](#custom-help) + - [Display help from code](#display-help-from-code) - [.usage and .name](#usage-and-name) - - [.help(cb)](#helpcb) - - [.outputHelp(cb)](#outputhelpcb) - - [.helpInformation()](#helpinformation) - [.helpOption(flags, description)](#helpoptionflags-description) - [.addHelpCommand()](#addhelpcommand) + - [More configuration](#more-configuration-2) - [Custom event listeners](#custom-event-listeners) - [Bits and pieces](#bits-and-pieces) - [.parse() and .parseAsync()](#parse-and-parseasync) - - [Avoiding option name clashes](#avoiding-option-name-clashes) + - [Parsing Configuration](#parsing-configuration) + - [Legacy options as properties](#legacy-options-as-properties) - [TypeScript](#typescript) - [createCommand()](#createcommand) - - [Import into ECMAScript Module](#import-into-ecmascript-module) - [Node options such as `--harmony`](#node-options-such-as---harmony) - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands) - - [Override exit handling](#override-exit-handling) + - [Override exit and output handling](#override-exit-and-output-handling) + - [Additional documentation](#additional-documentation) - [Examples](#examples) - [Support](#support) - [Commander for enterprise](#commander-for-enterprise) +For information about terms used in this document see: [terminology](./docs/terminology.md) + ## Installation ```bash @@ -70,24 +76,43 @@ const program = new Command(); program.version('0.0.1'); ``` +For named imports in ECMAScript modules, import from `commander/esm.mjs`. + +```js +// index.mjs +import { Command } from 'commander/esm.mjs'; +const program = new Command(); +``` + +And in TypeScript: + +```ts +// index.ts +import { Command } from 'commander'; +const program = new Command(); +``` + + ## Options Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|'). -The options can be accessed as properties on the Command object. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. See also optional new behaviour to [avoid name clashes](#avoiding-option-name-clashes). +The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler. +You can also use `.getOptionValue()` and `.setOptionValue()` to work with a single option value. -Multiple short flags may optionally be combined in a single argument following the dash: boolean flags, the last flag may take a value, and the value. +Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc. + +Multiple short flags may optionally be combined in a single argument following the dash: boolean flags, followed by a single option taking a value (possibly followed by the value). For example `-a -b -p 80` may be written as `-ab -p80` or even `-abp80`. You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted. -This is particularly useful for passing options through to another -command, like: `do -- git --version`. -Options on the command line are not positional, and can be specified before or after other command arguments. +By default options on the command line are not positional, and can be specified before or after other arguments. ### Common option types, boolean and value -The two most used option types are a boolean flag, and an option which takes a value (declared using angle brackets). Both are `undefined` unless specified on command line. +The two most used option types are a boolean option, and an option which takes its value +from the following argument (declared with angle brackets like `--expect `). Both are `undefined` unless specified on command line. Example file: [options-common.js](./examples/options-common.js) @@ -99,19 +124,17 @@ program program.parse(process.argv); -if (program.debug) console.log(program.opts()); +const options = program.opts(); +if (options.debug) console.log(options); console.log('pizza details:'); -if (program.small) console.log('- small pizza size'); -if (program.pizzaType) console.log(`- ${program.pizzaType}`); +if (options.small) console.log('- small pizza size'); +if (options.pizzaType) console.log(`- ${options.pizzaType}`); ``` ```bash -$ pizza-options -d -{ debug: true, small: undefined, pizzaType: undefined } -pizza details: $ pizza-options -p error: option '-p, --pizza-type ' argument missing -$ pizza-options -ds -p vegetarian +$ pizza-options -d -s -p vegetarian { debug: true, small: true, pizzaType: 'vegetarian' } pizza details: - small pizza size @@ -121,7 +144,7 @@ pizza details: - cheese ``` -`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array. +`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array. The parameter is optional and defaults to `process.argv`. ### Default option value @@ -133,9 +156,9 @@ Example file: [options-defaults.js](./examples/options-defaults.js) program .option('-c, --cheese ', 'add the specified type of cheese', 'blue'); -program.parse(process.argv); +program.parse(); -console.log(`cheese: ${program.cheese}`); +console.log(`cheese: ${program.opts().cheese}`); ``` ```bash @@ -145,13 +168,13 @@ $ pizza-options --cheese stilton cheese: stilton ``` -### Other option types, negatable boolean and flag|value +### Other option types, negatable boolean and boolean|value -You can specify a boolean option long name with a leading `no-` to set the option value to false when used. +You can define a boolean option long name with a leading `no-` to set the option value to false when used. Defined alone this also makes the option true by default. If you define `--foo` first, adding `--no-foo` does not change the default value from what it would -otherwise be. You can specify a default boolean value for a boolean flag and it can be overridden on command line. +otherwise be. You can specify a default boolean value for a boolean option and it can be overridden on command line. Example file: [options-negatable.js](./examples/options-negatable.js) @@ -160,10 +183,11 @@ program .option('--no-sauce', 'Remove sauce') .option('--cheese ', 'cheese flavour', 'mozzarella') .option('--no-cheese', 'plain with no cheese') - .parse(process.argv); + .parse(); -const sauceStr = program.sauce ? 'sauce' : 'no sauce'; -const cheeseStr = (program.cheese === false) ? 'no cheese' : `${program.cheese} cheese`; +const options = program.opts(); +const sauceStr = options.sauce ? 'sauce' : 'no sauce'; +const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.cheese} cheese`; console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`); ``` @@ -178,9 +202,10 @@ $ pizza-options --no-sauce --no-cheese You ordered a pizza with no sauce and no cheese ``` -You can specify an option which functions as a flag but may also take a value (declared using square brackets). +You can specify an option which may be used as a boolean option but may optionally take an option-argument +(declared with square brackets like `--optional [value]`). -Example file: [options-flag-or-value.js](./examples/options-flag-or-value.js) +Example file: [options-boolean-or-value.js](./examples/options-boolean-or-value.js) ```js program @@ -188,9 +213,10 @@ program program.parse(process.argv); -if (program.cheese === undefined) console.log('no cheese'); -else if (program.cheese === true) console.log('add cheese'); -else console.log(`add cheese type ${program.cheese}`); +const options = program.opts(); +if (options.cheese === undefined) console.log('no cheese'); +else if (options.cheese === true) console.log('add cheese'); +else console.log(`add cheese type ${options.cheese}`); ``` ```bash @@ -202,64 +228,7 @@ $ pizza-options --cheese mozzarella add cheese type mozzarella ``` -### Custom option processing - -You may specify a function to do custom processing of option values. The callback function receives two parameters, the user specified value and the -previous value for the option. It returns the new value for the option. - -This allows you to coerce the option value to the desired type, or accumulate values, or do entirely custom processing. - -You can optionally specify the default/starting value for the option after the function. - -Example file: [options-custom-processing.js](./examples/options-custom-processing.js) - -```js -function myParseInt(value, dummyPrevious) { - // parseInt takes a string and an optional radix - return parseInt(value); -} - -function increaseVerbosity(dummyValue, previous) { - return previous + 1; -} - -function collect(value, previous) { - return previous.concat([value]); -} - -function commaSeparatedList(value, dummyPrevious) { - return value.split(','); -} - -program - .option('-f, --float ', 'float argument', parseFloat) - .option('-i, --integer ', 'integer argument', myParseInt) - .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0) - .option('-c, --collect ', 'repeatable value', collect, []) - .option('-l, --list ', 'comma separated list', commaSeparatedList) -; - -program.parse(process.argv); - -if (program.float !== undefined) console.log(`float: ${program.float}`); -if (program.integer !== undefined) console.log(`integer: ${program.integer}`); -if (program.verbose > 0) console.log(`verbosity: ${program.verbose}`); -if (program.collect.length > 0) console.log(program.collect); -if (program.list !== undefined) console.log(program.list); -``` - -```bash -$ custom -f 1e2 -float: 100 -$ custom --integer 2 -integer: 2 -$ custom -v -v -v -verbose: 3 -$ custom -c a -c b -c c -[ 'a', 'b', 'c' ] -$ custom --list x,y,z -[ 'x', 'y', 'z' ] -``` +For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md). ### Required option @@ -271,7 +240,7 @@ Example file: [options-required.js](./examples/options-required.js) program .requiredOption('-c, --cheese ', 'pizza must have cheese'); -program.parse(process.argv); +program.parse(); ``` ```bash @@ -282,7 +251,7 @@ error: required option '-c, --cheese ' not specified ### Variadic option You may make an option variadic by appending `...` to the value placeholder when declaring the option. On the command line you -can then specify multiple option arguments, and the parsed option value will be an array. The extra arguments +can then specify multiple option-arguments, and the parsed option value will be an array. The extra arguments are read until the first argument starting with a dash. The special argument `--` stops option processing entirely. If a value is specified in the same argument as the option then no further values are read. @@ -311,6 +280,8 @@ Options: { number: [ '1', '2', '3' ], letter: true } Remaining arguments: [ 'operand' ] ``` +For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md). + ### Version option The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits. @@ -331,11 +302,102 @@ the same syntax for flags as the `option` method. program.version('0.0.1', '-v, --vers', 'output the current version'); ``` +### More configuration + +You can add most options using the `.option()` method, but there are some additional features available +by constructing an `Option` explicitly for less common cases. + +Example file: [options-extra.js](./examples/options-extra.js) + +```js +program + .addOption(new Option('-s, --secret').hideHelp()) + .addOption(new Option('-t, --timeout ', 'timeout in seconds').default(60, 'one minute')) + .addOption(new Option('-d, --drink ', 'drink size').choices(['small', 'medium', 'large'])); +``` + +```bash +$ extra --help +Usage: help [options] + +Options: + -t, --timeout timeout in seconds (default: one minute) + -d, --drink drink cup size (choices: "small", "medium", "large") + -h, --help display help for command + +$ extra --drink huge +error: option '-d, --drink ' argument 'huge' is invalid. Allowed choices are small, medium, large. +``` + +### Custom option processing + +You may specify a function to do custom processing of option-arguments. The callback function receives two parameters, +the user specified option-argument and the previous value for the option. It returns the new value for the option. + +This allows you to coerce the option-argument to the desired type, or accumulate values, or do entirely custom processing. + +You can optionally specify the default/starting value for the option after the function parameter. + +Example file: [options-custom-processing.js](./examples/options-custom-processing.js) + +```js +function myParseInt(value, dummyPrevious) { + // parseInt takes a string and a radix + const parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + throw new commander.InvalidArgumentError('Not a number.'); + } + return parsedValue; +} + +function increaseVerbosity(dummyValue, previous) { + return previous + 1; +} + +function collect(value, previous) { + return previous.concat([value]); +} + +function commaSeparatedList(value, dummyPrevious) { + return value.split(','); +} + +program + .option('-f, --float ', 'float argument', parseFloat) + .option('-i, --integer ', 'integer argument', myParseInt) + .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0) + .option('-c, --collect ', 'repeatable value', collect, []) + .option('-l, --list ', 'comma separated list', commaSeparatedList) +; + +program.parse(); + +const options = program.opts(); +if (options.float !== undefined) console.log(`float: ${options.float}`); +if (options.integer !== undefined) console.log(`integer: ${options.integer}`); +if (options.verbose > 0) console.log(`verbosity: ${options.verbose}`); +if (options.collect.length > 0) console.log(options.collect); +if (options.list !== undefined) console.log(options.list); +``` + +```bash +$ custom -f 1e2 +float: 100 +$ custom --integer 2 +integer: 2 +$ custom -v -v -v +verbose: 3 +$ custom -c a -c b -c c +[ 'a', 'b', 'c' ] +$ custom --list x,y,z +[ 'x', 'y', 'z' ] +``` + ## Commands You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)). -In the first parameter to `.command()` you specify the command name and any command arguments. The arguments may be `` or `[optional]`, and the last argument may also be `variadic...`. +In the first parameter to `.command()` you specify the command name. You may append the command-arguments after the command name, or specify them separately using `.argument()`. The arguments may be `` or `[optional]`, and the last argument may also be `variadic...`. You can use `.addCommand()` to add an already configured subcommand to the program. @@ -351,7 +413,7 @@ program console.log('clone command called'); }); -// Command implemented using stand-alone executable file (description is second parameter to `.command`) +// Command implemented using stand-alone executable file, indicated by adding description as second parameter to `.command`. // Returns `this` for adding more commands. program .command('start ', 'start named service') @@ -363,73 +425,107 @@ program .addCommand(build.makeBuildCommand()); ``` -Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `true` for `opts.hidden` will remove the command from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified ([example](./examples/defaultCommand.js)). +Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will +remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other +subcommand is specified ([example](./examples/defaultCommand.js)). + +### Command-arguments -### Specify the argument syntax +For subcommands, you can specify the argument syntax in the call to `.command()` (as shown above). This +is the only method usable for subcommands implemented using a stand-alone executable, but for other subcommands +you can instead use the following method. -You use `.arguments` to specify the arguments for the top-level command, and for subcommands they are usually included in the `.command` call. Angled brackets (e.g. ``) indicate required input. Square brackets (e.g. `[optional]`) indicate optional input. +To configure a command, you can use `.argument()` to specify each expected command-argument. +You supply the argument name and an optional description. The argument may be `` or `[optional]`. +You can specify a default value for an optional command-argument. -Example file: [env](./examples/env) +Example file: [argument.js](./examples/argument.js) ```js program .version('0.1.0') - .arguments(' [env]') - .action(function (cmd, env) { - cmdValue = cmd; - envValue = env; + .argument('', 'user to login') + .argument('[password]', 'password for user, if required', 'no password given') + .action((username, password) => { + console.log('username:', username); + console.log('password:', password); }); - -program.parse(process.argv); - -if (typeof cmdValue === 'undefined') { - console.error('no command given!'); - process.exit(1); -} -console.log('command:', cmdValue); -console.log('environment:', envValue || "no environment given"); ``` The last argument of a command can be variadic, and only the last argument. To make an argument variadic you - append `...` to the argument name. For example: + append `...` to the argument name. A variadic argument is passed to the action handler as an array. For example: ```js -const { program } = require('commander'); - program .version('0.1.0') - .command('rmdir [otherDirs...]') - .action(function (dir, otherDirs) { - console.log('rmdir %s', dir); - if (otherDirs) { - otherDirs.forEach(function (oDir) { - console.log('rmdir %s', oDir); - }); - } + .command('rmdir') + .argument('') + .action(function (dirs) { + dirs.forEach((dir) => { + console.log('rmdir %s', dir); + }); }); +``` -program.parse(process.argv); +There is a convenience method to add multiple arguments at once, but without descriptions: + +```js +program + .arguments(' '); ``` -The variadic argument is passed to the action handler as an array. +#### More configuration -### Action handler (sub)commands +There are some additional features available by constructing an `Argument` explicitly for less common cases. -You can add options to a command that uses an action handler. -The action handler gets passed a parameter for each argument you declared, and one additional argument which is the -command object itself. This command argument has the values for the command-specific options added as properties. +Example file: [arguments-extra.js](./examples/arguments-extra.js) ```js -const { program } = require('commander'); +program + .addArgument(new commander.Argument('', 'drink cup size').choices(['small', 'medium', 'large'])) + .addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute')) +``` + +#### Custom argument processing + +You may specify a function to do custom processing of command-arguments before they are passed to the action handler. +The callback function receives two parameters, the user specified command-argument and the previous value for the argument. +It returns the new value for the argument. + +You can optionally specify the default/starting value for the argument after the function parameter. +Example file: [arguments-custom-processing.js](./examples/arguments-custom-processing.js) + +```js program - .command('rm ') - .option('-r, --recursive', 'Remove recursively') - .action(function (dir, cmdObj) { - console.log('remove ' + dir + (cmdObj.recursive ? ' recursively' : '')) + .command('add') + .argument('', 'integer argument', myParseInt) + .argument('[second]', 'integer argument', myParseInt, 1000) + .action((first, second) => { + console.log(`${first} + ${second} = ${first + second}`); }) +; +``` -program.parse(process.argv) +### Action handler + +The action handler gets passed a parameter for each command-argument you declared, and two additional parameters +which are the parsed options and the command object itself. + +Example file: [thank.js](./examples/thank.js) + +```js +program + .argument('') + .option('-t, --title ', 'title to use before name') + .option('-d, --debug', 'display some debugging') + .action((name, options, command) => { + if (options.debug) { + console.error('Called %s with options %o', command.name(), options); + } + const title = options.title ? `${options.title} ` : ''; + console.log(`Thank-you ${title}${name}`); + }); ``` You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`. @@ -445,7 +541,8 @@ async function main() { } ``` -A command's options on the command line are validated when the command is used. Any unknown options will be reported as an error. +A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default it is not an error to +pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`. ### Stand-alone executable (sub)commands @@ -470,6 +567,33 @@ program.parse(process.argv); If the program is designed to be installed globally, make sure the executables have proper modes, like `755`. +### Life cycle hooks + +You can add callback hooks to a command for life cycle events. + +Example file: [hook.js](./examples/hook.js) + +```js +program + .option('-t, --trace', 'display trace statements for commands') + .hook('preAction', (thisCommand, actionCommand) => { + if (thisCommand.opts().trace) { + console.log(`About to call action handler for subcommand: ${actionCommand.name()}`); + console.log('arguments: %O', actionCommand.args); + console.log('options: %o', actionCommand.opts()); + } + }); +``` + +The callback hook can be `async`, in which case you call `.parseAsync` rather than `.parse`. You can add multiple hooks per event. + +The supported events are: + +- `preAction`: called before action handler for this command and its subcommands +- `postAction`: called after action handler for this command and its subcommands + +The hook is passed the command it was added to, and the command running the action handler. + ## Automated help The help information is auto-generated based on the information commander already knows about your program. The default @@ -481,10 +605,9 @@ Example file: [pizza](./examples/pizza) $ node ./examples/pizza --help Usage: pizza [options] -An application for pizzas ordering +An application for pizza ordering Options: - -V, --version output the version number -p, --peppers Add peppers -c, --cheese Add the specified type of cheese (default: "marble") -C, --no-cheese You do not want any cheese @@ -504,7 +627,7 @@ shell spawn --help ### Custom help -You can display extra information by listening for "--help". +You can add extra text to be displayed along with the built-in help. Example file: [custom-help](./examples/custom-help) @@ -512,12 +635,10 @@ Example file: [custom-help](./examples/custom-help) program .option('-f, --foo', 'enable some foo'); -// must be before .parse() -program.on('--help', () => { - console.log(''); - console.log('Example call:'); - console.log(' $ custom-help --help'); -}); +program.addHelpText('after', ` + +Example call: + $ custom-help --help`); ``` Yields the following help output: @@ -533,6 +654,28 @@ Example call: $ custom-help --help ``` +The positions in order displayed are: + +- `beforeAll`: add to the program for a global banner or header +- `before`: display extra information before built-in help +- `after`: display extra information after built-in help +- `afterAll`: add to the program for a global footer (epilog) + +The positions "beforeAll" and "afterAll" apply to the command and all its subcommands. + +The second parameter can be a string, or a function returning a string. The function is passed a context object for your convenience. The properties are: + +- error: a boolean for whether the help is being displayed due to a usage error +- command: the Command which is displaying the help + +### Display help from code + +`.help()`: display help information and exit immediately. You can optionally pass `{ error: true }` to display on stderr and exit with an error status. + +`.outputHelp()`: output help information without exiting. You can optionally pass `{ error: true }` to display on stderr. + +`.helpInformation()`: get the built-in command help information as a string for processing or displaying yourself. + ### .usage and .name These allow you to customise the usage description in the first line of the help. The name is otherwise @@ -550,23 +693,9 @@ The help will start with: Usage: my-command [global options] command ``` -### .help(cb) - -Output help information and exit immediately. Optional callback cb allows post-processing of help text before it is displayed. - -### .outputHelp(cb) - -Output help information without exiting. -Optional callback cb allows post-processing of help text before it is displayed. - -### .helpInformation() - -Get the command help information as a string for processing or displaying yourself. (The text does not include the custom help -from `--help` listeners.) - ### .helpOption(flags, description) -Override the default help flags and description. +By default every command has a help option. Override the default help flags and description. Pass false to disable the built-in help option. ```js program @@ -575,7 +704,7 @@ program ### .addHelpCommand() -You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`. +A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`. You can both turn on and customise the help command by supplying the name and description: @@ -583,13 +712,35 @@ You can both turn on and customise the help command by supplying the name and de program.addHelpCommand('assist [command]', 'show assistance'); ``` +### More configuration + +The built-in help is formatted using the Help class. +You can configure the Help behaviour by modifying data properties and methods using `.configureHelp()`, or by subclassing using `.createHelp()` if you prefer. + +The data properties are: + +- `helpWidth`: specify the wrap width, useful for unit tests +- `sortSubcommands`: sort the subcommands alphabetically +- `sortOptions`: sort the options alphabetically + +There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used. + +Example file: [configure-help.js](./examples/configure-help.js) + +``` +program.configureHelp({ + sortSubcommands: true, + subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage. +}); +``` + ## Custom event listeners You can execute custom actions by listening to command and option events. ```js program.on('option:verbose', function () { - process.env.VERBOSE = this.verbose; + process.env.VERBOSE = this.opts().verbose; }); program.on('command:*', function (operands) { @@ -620,47 +771,59 @@ program.parse(); // Implicit, and auto-detect electron program.parse(['-f', 'filename'], { from: 'user' }); ``` -### Avoiding option name clashes +### Parsing Configuration -The original and default behaviour is that the option values are stored -as properties on the program, and the action handler is passed a -command object with the options values stored as properties. -This is very convenient to code, but the downside is possible clashes with -existing properties of Command. +If the default parsing does not suit your needs, there are some behaviours to support other usage patterns. -There are two new routines to change the behaviour, and the default behaviour may change in the future: +By default program options are recognised before and after subcommands. To only look for program options before subcommands, use `.enablePositionalOptions()`. This lets you use +an option for a different purpose in subcommands. -- `storeOptionsAsProperties`: whether to store option values as properties on command object, or store separately (specify false) and access using `.opts()` -- `passCommandToAction`: whether to pass command to action handler, -or just the options (specify false) +Example file: [positional-options.js](./examples/positional-options.js) -Example file: [storeOptionsAsProperties-action.js](./examples/storeOptionsAsProperties-action.js) +With positional options, the `-b` is a program option in the first line and a subcommand option in the second line: -```js -program - .storeOptionsAsProperties(false) - .passCommandToAction(false); +```sh +program -b subcommand +program subcommand -b +``` -program - .name('my-program-name') - .option('-n,--name '); +By default options are recognised before and after command-arguments. To only process options that come +before the command-arguments, use `.passThroughOptions()`. This lets you pass the arguments and following options through to another program +without needing to use `--` to end the option processing. +To use pass through options in a subcommand, the program needs to enable positional options. -program - .command('show') - .option('-a,--action ') - .action((options) => { - console.log(options.action); - }); +Example file: [pass-through-options.js](./examples/pass-through-options.js) -program.parse(process.argv); +With pass through options, the `--port=80` is a program option in the first line and passed through as a command-argument in the second line: -const programOptions = program.opts(); -console.log(programOptions.name); +```sh +program --port=80 arg +program arg --port=80 ``` -### TypeScript +By default the option processing shows an error for an unknown option. To have an unknown option treated as an ordinary command-argument and continue looking for options, use `.allowUnknownOption()`. This lets you mix known and unknown options. -The Commander package includes its TypeScript Definition file. +By default the argument processing does not display an error for more command-arguments than expected. +To display an error for excess arguments, use`.allowExcessArguments(false)`. + +### Legacy options as properties + +Before Commander 7, the option values were stored as properties on the command. +This was convenient to code but the downside was possible clashes with +existing properties of `Command`. You can revert to the old behaviour to run unmodified legacy code by using `.storeOptionsAsProperties()`. + +```js +program + .storeOptionsAsProperties() + .option('-d, --debug') + .action((commandAndOptions) => { + if (commandAndOptions.debug) { + console.error(`Called ${commandAndOptions.name()}`); + } + }); +``` + +### TypeScript If you use `ts-node` and stand-alone executable subcommands written as `.ts` files, you need to call your program through node to get the subcommands called correctly. e.g. @@ -679,18 +842,7 @@ const program = createCommand(); `createCommand` is also a method of the Command object, and creates a new command rather than a subcommand. This gets used internally when creating subcommands using `.command()`, and you may override it to -customise the new subcommand (examples using [subclass](./examples/custom-command-class.js) and [function](./examples/custom-command-function.js)). - -### Import into ECMAScript Module - -Commander is currently a CommonJS package, and the default export can be imported into an ES Module: - -```js -// index.mjs -import commander from 'commander'; -const program = commander.program; -const newCommand = new commander.Command(); -``` +customise the new subcommand (example file [custom-command-class.js](./examples/custom-command-class.js)). ### Node options such as `--harmony` @@ -708,7 +860,7 @@ the inspector port is incremented by 1 for the spawned subcommand. If you are using VSCode to debug executable subcommands you need to set the `"autoAttachChildProcesses": true` flag in your launch.json configuration. -### Override exit handling +### Override exit and output handling By default Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override this behaviour and optionally supply a callback. The default override throws a `CommanderError`. @@ -726,53 +878,104 @@ try { } ``` +By default Commander is configured for a command-line application and writes to stdout and stderr. +You can modify this behaviour for custom applications. In addition, you can modify the display of error messages. + +Example file: [configure-output.js](./examples/configure-output.js) + + +```js +function errorColor(str) { + // Add ANSI escape codes to display text in red. + return `\x1b[31m${str}\x1b[0m`; +} + +program + .configureOutput({ + // Visibly override write routines as example! + writeOut: (str) => process.stdout.write(`[OUT] ${str}`), + writeErr: (str) => process.stdout.write(`[ERR] ${str}`), + // Highlight errors in color. + outputError: (str, write) => write(errorColor(str)) + }); +``` + +### Additional documentation + +There is more information available about: + +- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility +- [options taking varying arguments](./docs/options-taking-varying-arguments.md) + ## Examples -Example file: [deploy](./examples/deploy) +In a single command program, you might not need an action handler. + +Example file: [pizza](./examples/pizza) ```js const { program } = require('commander'); program - .version('0.1.0') - .option('-C, --chdir ', 'change the working directory') - .option('-c, --config ', 'set config path. defaults to ./deploy.conf') - .option('-T, --no-tests', 'ignore test hook'); + .description('An application for pizza ordering') + .option('-p, --peppers', 'Add peppers') + .option('-c, --cheese ', 'Add the specified type of cheese', 'marble') + .option('-C, --no-cheese', 'You do not want any cheese'); + +program.parse(); + +const options = program.opts(); +console.log('you ordered a pizza with:'); +if (options.peppers) console.log(' - peppers'); +const cheese = !options.cheese ? 'no' : options.cheese; +console.log(' - %s cheese', cheese); +``` + +In a multi-command program, you will have action handlers for each command (or stand-alone executables for the commands). + +Example file: [deploy](./examples/deploy) + +```js +const { Command } = require('commander'); +const program = new Command(); + +program + .version('0.0.1') + .option('-c, --config ', 'set config path', './deploy.conf'); program .command('setup [env]') .description('run setup commands for all envs') - .option("-s, --setup_mode [mode]", "Which setup mode to use") - .action(function(env, options){ - const mode = options.setup_mode || "normal"; + .option('-s, --setup_mode ', 'Which setup mode to use', 'normal') + .action((env, options) => { env = env || 'all'; - console.log('setup for %s env(s) with %s mode', env, mode); + console.log('read config from %s', program.opts().config); + console.log('setup for %s env(s) with %s mode', env, options.setup_mode); }); program - .command('exec ') + .command('exec