Skip to content
Myr

Factory routine to create a new unattached argument (#1497)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Factory routine to create a new unattached argument * ESM export improvements * createArgument ESM test * Add typings for createArgument * Add tests for createArgument

authored by Sergei Vizel · committed by GitHub · parent 0504945 · Browse files · 6 files+83 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: John Gee <john@ruru.gen.nz>

Diff stats

6 files+83 added−3 removed

  • tests:+43 added−1 removed
  • other:+40 added−2 removed

6 files+83 added−3 removed

added:tests/command.createArgument.test.js+40 added
modified:tests/esm-imports-test.mjs+3 added-1 removed
modified:typings/index.d.ts+8 added
248 unmodified lines
249 */250 addCommand(cmd: Command, opts?: CommandOptions): this;251252 /**253 * Factory routine to create a new unattached argument.254 *255 * See .argument() for creating an attached argument, which uses this routine to256 * create the argument. You can override createArgument to return a custom argument.257 */258 createArgument(name: string, description?: string): Argument;259260 /**261 * Define argument syntax for command.262 *263 * The default is that the argument is required, and you can explicitly264 * indicate this with <> around the name. Put [] around the name for an optional argument.
419 unmodified lines
modified:typings/index.test-d.ts+4 added
343 unmodified lines
344345// Argument methods346// name347expectType<string>(baseArgument.name());348349// createArgument350expectType<commander.Argument>(program.createArgument('<name>'));351expectType<commander.Argument>(program.createArgument('<name>', 'description'));
modified:esm.mjs+12 added-1 removed
modified:index.js+16 added-1 removed
835 unmodified lines
836 return this;837 };838839 /**840 * Factory routine to create a new unattached argument.841 *842 * See .argument() for creating an attached argument, which uses this routine to843 * create the argument. You can override createArgument to return a custom argument.844 *845 * @param {string} name846 * @param {string} [description]847 * @return {Argument} new argument848 */849850 createArgument(name, description) {851 return new Argument(name, description);852 };853854 /**855 * Define argument syntax for command.856 *857 * The default is that the argument is required, and you can explicitly858 * indicate this with <> around the name. Put [] around the name for an optional argument.
7 unmodified lines
866 * @param {string} [description]867 * @return {Command} `this` command for chaining868 */869 argument(name, description) {855 const argument = new Argument(name, description);870 const argument = this.createArgument(name, description);871 this.addArgument(argument);872 return this;873 }874
1450 unmodified lines