Add Option.implies() (#1724)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by GitHub · parent 1b492d9 · Browse files · 9 files·+430 added−25 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+430 added−25 removed
- tests:+273 added−0 removed
- other:+157 added−25 removed
Provenance
- Commit
d660967- Tree
fc05392- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
1b492d9
9 files changed+430 added−25 removed
modified:examples/options-extra.js+3 added-1 removed
12 unmodified lines131415161717181920212223242526272829303112 unmodified lines .addOption(new Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute')) .addOption(new Option('-d, --drink <size>', 'drink cup size').choices(['small', 'medium', 'large'])) .addOption(new Option('-p, --port <number>', 'port number').env('PORT')) .addOption(new Option('--donate [amount]', 'optional donation in dollars').preset('20').argParser(parseFloat)) .addOption(new Option('--disable-server', 'disables the server').conflicts('port')); .addOption(new Option('--disable-server', 'disables the server').conflicts('port')) .addOption(new Option('--free-drink', 'small drink included free ').implies({ drink: 'small' }));
program.parse();
console.log('Options: ', program.opts());
// Try the following:// node options-extra.js --help// node options-extra.js --drink huge// node options-extra.js --free-drink// PORT=80 node options-extra.js// node options-extra.js --donate// node options-extra.js --donate 30.50// node options-extra.js --disable-server --port 8000added:examples/options-implies.js+22 added
12345678910111213141516171819202122#!/usr/bin/env node// const { Command, Option } = require('commander'); // (normal include)const { Command, Option } = require('../'); // include commander in git clone of commander repoconst program = new Command();
// You can use .conflicts() with a single string, which is the camel-case name of the conflicting option.program .addOption(new Option('--quiet').implies({ logLevel: 'off' })) .addOption(new Option('--log-level <level>').choices(['info', 'warning', 'error', 'off']).default('info')) .addOption(new Option('-c, --cheese <type>', 'Add the specified type of cheese').implies({ dairy: true })) .addOption(new Option('--no-cheese', 'You do not want any cheese').implies({ dairy: false })) .addOption(new Option('--dairy', 'May contain dairy'));
program.parse();console.log(program.opts());
// Try the following:// node options-implies.js// node options-implies.js --quiet// node options-implies.js --log-level=warning --quiet// node options-implies.js --cheese=cheddar// node options-implies.js --no-cheesemodified:lib/command.js+25 added-1 removed
5 unmodified lines6 7 const { Argument, humanReadableArgName } = require('./argument.js');8 const { CommanderError } = require('./error.js');9 const { Help } = require('./help.js');10-const { Option, splitOptionFlags } = require('./option.js');10+const { Option, splitOptionFlags, DualOptions } = require('./option.js');11 const { suggestSimilar } = require('./suggestSimilar');12 13 // @ts-check14 1178 unmodified lines1193 1194 _parseCommand(operands, unknown) {1195 const parsed = this.parseOptions(unknown);1196 this._parseOptionsEnv(); // after cli, so parseArg not called on both cli and env1197+ this._parseOptionsImplied();1198 operands = operands.concat(parsed.operands);1199 unknown = parsed.unknown;1200 this.args = operands.concat(unknown);1201 368 unmodified lines1570 });1571 }1572 1573 /**1574+ * Apply any implied option values, if option is undefined or default value.1575+ *1576+ * @api private1577+ */1578+ _parseOptionsImplied() {1579+ const dualHelper = new DualOptions(this.options);1580+ const hasCustomOptionValue = (optionKey) => {1581+ return this.getOptionValue(optionKey) !== undefined && !['default', 'implied'].includes(this.getOptionValueSource(optionKey));1582+ };1583+ this.options1584+ .filter(option => (option.implied !== undefined) &&1585+ hasCustomOptionValue(option.attributeName()) &&1586+ dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option))1587+ .forEach((option) => {1588+ Object.keys(option.implied)1589+ .filter(impliedKey => !hasCustomOptionValue(impliedKey))1590+ .forEach(impliedKey => {1591+ this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], 'implied');1592+ });1593+ });1594+ }1595+1596+ /**1597 * Argument `name` is missing.1598 *1599 * @param {string} name1600 * @api private522 unmodified linesmodified:lib/option.js+67 added
32 unmodified lines33 this.parseArg = undefined;34 this.hidden = false;35 this.argChoices = undefined;36 this.conflictsWith = [];37+ this.implied = undefined;38 }39 40 /**41 * Set the default value, and optionally supply the description to be displayed in the help.43 unmodified lines85 return this;86 }87 88 /**89+ * Specify implied option values for when this option is set and the implied options are not.90+ *91+ * The custom processing (parseArg) is not called on the implied values.92+ *93+ * @example94+ * program95+ * .addOption(new Option('--log', 'write logging information to file'))96+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));97+ *98+ * @param {Object} impliedOptionValues99+ * @return {Option}100+ */101+ implies(impliedOptionValues) {102+ this.implied = Object.assign(this.implied || {}, impliedOptionValues);103+ return this;104+ }105+106+ /**107 * Set environment variable to check for option value.108 * Priority order of option values is default < env < cli109 *110 * @param {string} name125 unmodified lines236 }237 }238 239 /**240+ * This class is to make it easier to work with dual options, without changing the existing241+ * implementation. We support separate dual options for separate positive and negative options,242+ * like `--build` and `--no-build`, which share a single option value. This works nicely for some243+ * use cases, but is tricky for others where we want separate behaviours despite244+ * the single shared option value.245+ */246+class DualOptions {247+ /**248+ * @param {Option[]} options249+ */250+ constructor(options) {251+ this.positiveOptions = new Map();252+ this.negativeOptions = new Map();253+ this.dualOptions = new Set();254+ options.forEach(option => {255+ if (option.negate) {256+ this.negativeOptions.set(option.attributeName(), option);257+ } else {258+ this.positiveOptions.set(option.attributeName(), option);259+ }260+ });261+ this.negativeOptions.forEach((value, key) => {262+ if (this.positiveOptions.has(key)) {263+ this.dualOptions.add(key);264+ }265+ });266+ }267+268+ /**269+ * Did the value come from the option, and not from possible matching dual option?270+ *271+ * @param {any} value272+ * @param {Option} option273+ * @returns {boolean}274+ */275+ valueFromOption(value, option) {276+ const optionKey = option.attributeName();277+ if (!this.dualOptions.has(optionKey)) return true;278+279+ // Use the value to deduce if (probably) came from the option.280+ const preset = this.negativeOptions.get(optionKey).presetArg;281+ const negativeValue = (preset !== undefined) ? preset : false;282+ return option.negate === (negativeValue === value);283+ }284+}285+286+/**287 * Convert string from kebab-case to camelCase.288 *289 * @param {string} str290 * @return {string}29 unmodified lines320 }321 322 exports.Option = Option;323 exports.splitOptionFlags = splitOptionFlags;324+exports.DualOptions = DualOptions;added:tests/options.dual-options.test.js+101 added
1+const { Option, DualOptions } = require('../lib/option.js');2+const { Command } = require('../');3+4+// This tests an internal helper class which is not currently exposed on the package.5+6+test('when positive option then stored in positiveOptions', () => {7+ const program = new Command();8+ program.option('--one');9+ const helper = new DualOptions(program.options);10+ expect(helper.positiveOptions.size).toEqual(1);11+ expect(helper.negativeOptions.size).toEqual(0);12+ expect(helper.dualOptions.size).toEqual(0);13+});14+15+test('when negative option then stored in negativeOptions', () => {16+ const program = new Command();17+ program.option('--no-one');18+ const helper = new DualOptions(program.options);19+ expect(helper.positiveOptions.size).toEqual(0);20+ expect(helper.negativeOptions.size).toEqual(1);21+ expect(helper.dualOptions.size).toEqual(0);22+});23+24+test('when unrelated positive and negative options then no dual options', () => {25+ const program = new Command();26+ program27+ .option('--one')28+ .option('--no-two');29+ const helper = new DualOptions(program.options);30+ expect(helper.dualOptions.size).toEqual(0);31+});32+33+test('when related positive and negative options then stored as dual option', () => {34+ const program = new Command();35+ program36+ .option('--one')37+ .option('--no-one');38+ const helper = new DualOptions(program.options);39+ expect(helper.dualOptions.size).toEqual(1);40+});41+42+test('when related negative and positive options then stored as dual option', () => {43+ const program = new Command();44+ program45+ .option('--no-one')46+ .option('--one');47+ const helper = new DualOptions(program.options);48+ expect(helper.dualOptions.size).toEqual(1);49+});50+51+describe('valueFromOption with boolean option', () => {52+ const positiveOption = new Option('--one');53+ const negativeOption = new Option('--no-one');54+ const options = [positiveOption, negativeOption];55+56+ test('when negativeOption with false then return true', () => {57+ const helper = new DualOptions(options);58+ expect(helper.valueFromOption(false, negativeOption)).toBe(true);59+ });60+61+ test('when negativeOption with true then return false', () => {62+ const helper = new DualOptions(options);63+ expect(helper.valueFromOption(true, negativeOption)).toBe(false);64+ });65+66+ test('when positiveOption with false then return false', () => {67+ const helper = new DualOptions(options);68+ expect(helper.valueFromOption(false, positiveOption)).toBe(false);69+ });70+71+ test('when positiveOption with true then return true', () => {72+ const helper = new DualOptions(options);73+ expect(helper.valueFromOption(true, positiveOption)).toBe(true);74+ });75+});76+77+describe('valueFromOption with option expecting value and negative with preset', () => {78+ const positiveOption = new Option('--one <value>');79+ const negativeOption = new Option('--no-one').preset('FALSE');80+ const options = [positiveOption, negativeOption];81+82+ test('when negativeOption with FALSE then return true', () => {83+ const helper = new DualOptions(options);84+ expect(helper.valueFromOption('FALSE', negativeOption)).toBe(true);85+ });86+87+ test('when negativeOption with string then return false', () => {88+ const helper = new DualOptions(options);89+ expect(helper.valueFromOption('foo', negativeOption)).toBe(false);90+ });91+92+ test('when positiveOption with FALSE then return false', () => {93+ const helper = new DualOptions(options);94+ expect(helper.valueFromOption('FALSE', positiveOption)).toBe(false);95+ });96+97+ test('when positiveOption with true then return true', () => {98+ const helper = new DualOptions(options);99+ expect(helper.valueFromOption('foo', positiveOption)).toBe(true);100+ });101+});added:tests/options.implies.test.js+172 added
1+const { Command, Option } = require('../');2+3+describe('check priorities', () => {4+ test('when source undefined and implied undefined then implied is undefined', () => {5+ const program = new Command();6+ program7+ .addOption(new Option('--foo').implies({ bar: 'implied' }))8+ .option('--bar');9+ program.parse([], { from: 'user' });10+ expect(program.opts()).toEqual({});11+ });12+13+ test('when source default and implied undefined then implied is undefined', () => {14+ const program = new Command();15+ program16+ .addOption(new Option('--foo').implies({ bar: 'implied' }).default('default'))17+ .option('--bar');18+ program.parse([], { from: 'user' });19+ expect(program.opts()).toEqual({ foo: 'default' });20+ });21+22+ test('when source from env and implied undefined then implied is implied', () => {23+ const program = new Command();24+ const envName = 'COMMANDER_TEST_DELETE_ME';25+ process.env[envName] = 'env';26+ program27+ .addOption(new Option('--foo').implies({ bar: 'implied' }).env(envName))28+ .option('--bar');29+ program.parse([], { from: 'user' });30+ expect(program.opts()).toEqual({ foo: true, bar: 'implied' });31+ delete process.env[envName];32+ });33+34+ test('when source from cli and implied undefined then implied is implied', () => {35+ const program = new Command();36+ program37+ .addOption(new Option('--foo').implies({ bar: 'implied' }))38+ .option('--bar');39+ program.parse(['--foo'], { from: 'user' });40+ expect(program.opts()).toEqual({ foo: true, bar: 'implied' });41+ });42+43+ test('when source cli and implied default then implied is implied', () => {44+ const program = new Command();45+ program46+ .addOption(new Option('--foo').implies({ bar: 'implied' }))47+ .option('--bar', '', 'default');48+ program.parse(['--foo'], { from: 'user' });49+ expect(program.opts()).toEqual({ foo: true, bar: 'implied' });50+ });51+52+ test('when source cli and env default then implied is env', () => {53+ const program = new Command();54+ const envName = 'COMMANDER_TEST_DELETE_ME';55+ process.env[envName] = 'env';56+ program57+ .addOption(new Option('--foo').implies({ bar: 'implied' }))58+ .addOption(new Option('--bar <value>').env(envName));59+ program.parse(['--foo'], { from: 'user' });60+ expect(program.opts()).toEqual({ foo: true, bar: 'env' });61+ delete process.env[envName];62+ });63+});64+65+test('when imply non-option then ok and stored', () => {66+ const program = new Command();67+ program68+ .addOption(new Option('--foo').implies({ bar: 'implied' }));69+ program.parse(['--foo'], { from: 'user' });70+ expect(program.opts()).toEqual({ foo: true, bar: 'implied' });71+});72+73+test('when imply multiple values then store multiple values', () => {74+ const program = new Command();75+ program76+ .addOption(new Option('--foo').implies({ one: 'ONE', two: 'TWO' }))77+ .option('--one')78+ .option('--two');79+ program.parse(['--foo'], { from: 'user' });80+ expect(program.opts()).toEqual({ foo: true, one: 'ONE', two: 'TWO' });81+});82+83+test('when imply multiple times then store multiple values', () => {84+ const program = new Command();85+ program86+ .addOption(new Option('--foo').implies({ one: 'ONE' }).implies({ two: 'TWO' }))87+ .option('--one')88+ .option('--two');89+ program.parse(['--foo'], { from: 'user' });90+ expect(program.opts()).toEqual({ foo: true, one: 'ONE', two: 'TWO' });91+});92+93+test('when imply from positive option then positive implied', () => {94+ const program = new Command();95+ program96+ .addOption(new Option('--foo').implies({ implied: 'POSITIVE' }))97+ .addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }));98+ program.parse(['--foo'], { from: 'user' });99+ expect(program.opts()).toEqual({ foo: true, implied: 'POSITIVE' });100+});101+102+test('when imply from negative option then negative implied', () => {103+ const program = new Command();104+ program105+ .addOption(new Option('--foo').implies({ implied: 'POSITIVE' }))106+ .addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }));107+ program.parse(['--no-foo'], { from: 'user' });108+ expect(program.opts()).toEqual({ foo: false, implied: 'NEGATIVE' });109+});110+111+test('when imply from lone negative option then negative implied', () => {112+ const program = new Command();113+ program114+ .addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }));115+ program.parse(['--no-foo'], { from: 'user' });116+ expect(program.opts()).toEqual({ foo: false, implied: 'NEGATIVE' });117+});118+119+test('when imply from negative option with preset then negative implied', () => {120+ const program = new Command();121+ program122+ .addOption(new Option('--foo').implies({ implied: 'POSITIVE' }))123+ .addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }).preset('FALSE'));124+ program.parse(['--no-foo'], { from: 'user' });125+ expect(program.opts()).toEqual({ foo: 'FALSE', implied: 'NEGATIVE' });126+});127+128+test('when chained implies then only explicitly trigger', () => {129+ const program = new Command();130+ program131+ .addOption(new Option('--one').implies({ two: true }))132+ .addOption(new Option('--two').implies({ three: true }))133+ .addOption(new Option('--three'));134+ program.parse(['--one'], { from: 'user' });135+ expect(program.opts()).toEqual({ one: true, two: true });136+});137+138+test('when looped implies then no infinite loop', () => {139+ const program = new Command();140+ program141+ .addOption(new Option('--ying').implies({ yang: true }))142+ .addOption(new Option('--yang').implies({ ying: true }));143+ program.parse(['--ying'], { from: 'user' });144+ expect(program.opts()).toEqual({ ying: true, yang: true });145+});146+147+test('when conflict with implied value then throw', () => {148+ const program = new Command();149+ program150+ .exitOverride()151+ .configureOutput({152+ writeErr: () => {}153+ })154+ .addOption(new Option('--unary'))155+ .addOption(new Option('--binary').conflicts('unary'))156+ .addOption(new Option('--one').implies({ unary: true }));157+158+ expect(() => {159+ program.parse(['--binary', '--one'], { from: 'user' });160+ }).toThrow();161+});162+163+test('when requiredOption with implied value then not throw', () => {164+ const program = new Command();165+ program166+ .requiredOption('--target <target-file>')167+ .addOption(new Option('--default-target').implies({ target: 'default-file' }));168+169+ expect(() => {170+ program.parse(['--default-target'], { from: 'user' });171+ }).not.toThrow();172+});modified:typings/index.d.ts+12 added
129 unmodified lines130 */131 conflicts(names: string | string[]): this;132 133 /**134+ * Specify implied option values for when this option is set and the implied options are not.135+ *136+ * The custom processing (parseArg) is not called on the implied values.137+ *138+ * @example139+ * program140+ * .addOption(new Option('--log', 'write logging information to file'))141+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));142+ */143+ implies(optionValues: OptionValues): this;144+145+ /**146 * Set environment variable to check for option value.147 * Priority order of option values is default < env < cli148 */149 env(name: string): this;718 unmodified linesmodified:typings/index.test-d.ts+3 added
416 unmodified lines417 // conflicts418 expectType<commander.Option>(baseOption.conflicts('a'));419 expectType<commander.Option>(baseOption.conflicts(['a', 'b']));420 421+// implies422+expectType<commander.Option>(baseOption.implies({ option: 'VALUE', colour: false }));423+424 // name425 expectType<string>(baseOption.name());426 427 // attributeName37 unmodified linesmodified:Readme.md+25 added-23 removed
55 unmodified lines56 For information about terms used in this document see: [terminology](./docs/terminology.md)57 58 ## Installation59 60-```bash60+```sh61 npm install commander62 ```63 64 ## Quick Start20 unmodified lines85 const limit = options.first ? 1 : undefined;86 console.log(program.args[0].split(options.separator, limit));87 ```88 89-```sh89+```console90 $ node split.js -s / --fits a/b/c91 error: unknown option '--fits'92 (Did you mean --first?)93 $ node split.js -s / --first a/b/c25 unmodified lines119 120 program.parse();121 ```122 123-```sh123+```console124 $ node string-util.js help split125 Usage: string-util split [options] <string>126 127 Split a string into substrings and display as an array.51 unmodified lines179 Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc.180 181 An option and its option-argument can be separated by a space, or combined into the same argument. The option-argument can follow the short option directly or follow an `=` for a long option.182 183-```bash183+```sh184 serve -p 80185 serve -p80186 serve --port 80187 serve --port=8030 unmodified lines218 if (options.small) console.log('- small pizza size');219 if (options.pizzaType) console.log(`- ${options.pizzaType}`);220 ```221 222-```bash222+```console223 $ pizza-options -p224 error: option '-p, --pizza-type <type>' argument missing225 $ pizza-options -d -s -p vegetarian226 { debug: true, small: true, pizzaType: 'vegetarian' }27 unmodified lines254 255 console.log(`cheese: ${program.opts().cheese}`);256 ```257 258-```bash258+```console259 $ pizza-options260 cheese: blue261 $ pizza-options --cheese stilton262 cheese: stilton21 unmodified lines284 const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.cheese} cheese`;285 console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`);286 ```287 288-```bash288+```console289 $ pizza-options290 You ordered a pizza with sauce and mozzarella cheese291 $ pizza-options --sauce292 error: unknown option '--sauce'19 unmodified lines312 else if (options.cheese === true) console.log('add cheese');313 else console.log(`add cheese type ${options.cheese}`);314 ```315 316-```bash316+```console317 $ pizza-options318 no cheese319 $ pizza-options --cheese320 add cheese18 unmodified lines339 340 program.parse();341 ```342 343-```bash343+```console344 $ pizza345 error: required option '-c, --cheese <type>' not specified346 ```347 16 unmodified lines364 console.log('Options: ', program.opts());365 console.log('Remaining arguments: ', program.args);366 ```367 368-```bash368+```console369 $ collect -n 1 2 3 --letter a b c370 Options: { number: [ '1', '2', '3' ], letter: [ 'a', 'b', 'c' ] }371 Remaining arguments: []372 $ collect --letter=A -n80 operand13 unmodified lines386 ```js387 program.version('0.0.1');388 ```389 390-```bash390+```console391 $ ./examples/pizza -V392 0.0.1393 ```394 8 unmodified lines403 404 You can add most options using the `.option()` method, but there are some additional features available405 by constructing an `Option` explicitly for less common cases.406 407-Example files: [options-extra.js](./examples/options-extra.js), [options-env.js](./examples/options-env.js), [options-conflicts.js](./examples/options-conflicts.js)407+Example files: [options-extra.js](./examples/options-extra.js), [options-env.js](./examples/options-env.js), [options-conflicts.js](./examples/options-conflicts.js), [options-implies.js](./examples/options-implies.js)408 409 ```js410 program411 .addOption(new Option('-s, --secret').hideHelp())412 .addOption(new Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute'))413 .addOption(new Option('-d, --drink <size>', 'drink size').choices(['small', 'medium', 'large']))414 .addOption(new Option('-p, --port <number>', 'port number').env('PORT'))415 .addOption(new Option('--donate [amount]', 'optional donation in dollars').preset('20').argParser(parseFloat))416- .addOption(new Option('--disable-server', 'disables the server').conflicts('port'));416+ .addOption(new Option('--disable-server', 'disables the server').conflicts('port'))417+ .addOption(new Option('--free-drink', 'small drink included free ').implies({ drink: 'small' }));418 ```419 419-```bash420+```console421 $ extra --help422 Usage: help [options]423 424 Options:425 -t, --timeout <delay> timeout in seconds (default: one minute)426 -d, --drink <size> drink cup size (choices: "small", "medium", "large")427 -p, --port <number> port number (env: PORT)427- --donate [amount] optional donation in dollars (preset: 20)428+ --donate [amount] optional donation in dollars (preset: "20")429 --disable-server disables the server430+ --free-drink small drink included free431 -h, --help display help for command432 433 $ extra --drink huge434 error: option '-d, --drink <size>' argument 'huge' is invalid. Allowed choices are small, medium, large.435 434-$ PORT=80 extra --donate435-Options: { timeout: 60, donate: 20, port: '80' }436+$ PORT=80 extra --donate --free-drink437+Options: { timeout: 60, donate: 20, port: '80', freeDrink: true, drink: 'small' }438 439 $ extra --disable-server --port 8000440 error: option '--disable-server' cannot be used with option '-p, --port <number>'441 ```48 unmodified lines490 if (options.collect.length > 0) console.log(options.collect);491 if (options.list !== undefined) console.log(options.list);492 ```493 492-```bash494+```console495 $ custom -f 1e2496 float: 100497 $ custom --integer 2498 integer: 2230 unmodified lines729 help option is `-h,--help`.730 731 Example file: [pizza](./examples/pizza)732 731-```bash733+```console734 $ node ./examples/pizza --help735 Usage: pizza [options]736 737 An application for pizza ordering7 unmodified lines745 746 A `help` command is added by default if your command has subcommands. It can be used alone, or with a subcommand name to show747 further help for the subcommand. These are effectively the same if the `shell` program has implicit help:748 747-```bash749+```sh750 shell help751 shell --help752 753 shell help spawn53 unmodified lines807 // or808 program.showHelpAfterError('(add --help for additional information)');809 ```810 809-```sh811+```console812 $ pizza --unknown813 error: unknown option '--unknown'814 (add --help for additional information)815 ```3 unmodified lines819 ```js820 program.showSuggestionAfterError();821 ```822 821-```sh823+```console824 $ pizza --hepl825 error: unknown option '--hepl'826 (Did you mean --help?)827 ```164 unmodified lines992 ### TypeScript993 994 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.995 994-```bash996+```sh997 node -r ts-node/register pm.ts998 ```999 1000 ### createCommand()98 unmodified lines