Skip to content
Myr

Consistently refer to returning this for chaining (not parent) (#1231)

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 2c0a237 · Browse files · 2 files+26 added−26 removed
This commit

State

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

Diff stats

2 files+26 added−26 removed

  • other:+26 added−26 removed

2 files+26 added−26 removed

modified:typings/index.d.ts+13 added-13 removed
79 unmodified lines
80 *81 * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`82 * @param description - description of executable command83 * @param opts - configuration options84 * @returns top level command for chaining more command definitions84 * @returns `this` command for chaining85 */86 command(nameAndArgs: string, description: string, opts?: commander.CommandOptions): this;8788 /**
8 unmodified lines
97 * Add a prepared subcommand.98 *99 * See .command() for creating an attached subcommand which inherits settings from its parent.100 *101 * @returns parent command for chaining101 * @returns `this` command for chaining102 */103 addCommand(cmd: Command): this;104105 /**106 * Define argument syntax for command.107 *108 * @returns Command for chaining108 * @returns `this` command for chaining109 */110 arguments(desc: string): this;111112 /**
11 unmodified lines
124 * .action(function() {125 * // output help here126 * });127 *128 * @returns Command for chaining128 * @returns `this` command for chaining129 */130 action(fn: (...args: any[]) => void | Promise<void>): this;131132 /**
35 unmodified lines
168 *169 * // optional argument170 * program.option('-c, --cheese [type]', 'add cheese [marble]');171 *172 * @returns Command for chaining172 * @returns `this` command for chaining173 */174 option(flags: string, description?: string, defaultValue?: string | boolean): this;175 option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;176 option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
11 unmodified lines
188 /**189 * Whether to store option values as properties on command object,190 * or store separately (specify false). In both cases the option values can be accessed using .opts().191 *192 * @return Command for chaining192 * @returns `this` command for chaining193 */194 storeOptionsAsProperties(value?: boolean): this;195196 /**197 * Whether to pass command to action handler,198 * or just the options (specify false).199 *200 * @return Command for chaining200 * @returns `this` command for chaining201 */202 passCommandToAction(value?: boolean): this;203204 /**205 * Allow unknown options on the command line.206 *207 * @param [arg] if `true` or omitted, no error will be thrown for unknown options.208 * @returns Command for chaining208 * @returns `this` command for chaining209 */210 allowUnknownOption(arg?: boolean): this;211212 /**
7 unmodified lines
220 * program.parse(process.argv);221 * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions222 * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]223 *224 * @returns Command for chaining224 * @returns `this` command for chaining225 */226 parse(argv?: string[], options?: ParseOptions): this;227228 /**
34 unmodified lines
263264 /**265 * Set the description.266 *267 * @returns Command for chaining267 * @returns `this` command for chaining268 */269 description(str: string, argsDescription?: {[argName: string]: string}): this;270 /**271 * Get the description.
2 unmodified lines
274275 /**276 * Set an alias for the command.277 *278 * @returns Command for chaining278 * @returns `this` command for chaining279 */280 alias(alias: string): this;281 /**282 * Get alias for the command.
2 unmodified lines
285286 /**287 * Set the command usage.288 *289 * @returns Command for chaining289 * @returns `this` command for chaining290 */291 usage(str: string): this;292 /**293 * Get the command usage.
2 unmodified lines
296297 /**298 * Set the name of the command.299 *300 * @returns Command for chaining300 * @returns `this` command for chaining301 */302 name(str: string): this;303 /**304 * Get the name of the command.
64 unmodified lines
modified:index.js+13 added-13 removed
214 unmodified lines
215 *216 * See .command() for creating an attached subcommand which inherits settings from its parent.217 *218 * @param {Command} cmd - new subcommand219 * @return {Command} parent command for chaining219 * @return {Command} `this` command for chaining220 * @api public221 */222223 addCommand(cmd) {
32 unmodified lines
256 * addHelpCommand() // force on257 * addHelpCommand(false); // force off258 * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom detais259 *260 * @return {Command} for chaining260 * @return {Command} `this` command for chaining261 * @api public262 */263264 addHelpCommand(enableOrNameAndArgs, description) {
27 unmodified lines
292 *293 * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.294 *295 * @param {Array} args296 * @return {Command} for chaining296 * @return {Command} `this` command for chaining297 * @api private298 */299300 _parseExpectedArgs(args) {
34 unmodified lines
335 /**336 * Register callback to use as replacement for calling process.exit.337 *338 * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing339 * @return {Command} for chaining339 * @return {Command} `this` command for chaining340 * @api public341 */342343 exitOverride(fn) {
41 unmodified lines
385 * // output help here386 * });387 *388 * @param {Function} fn389 * @return {Command} for chaining389 * @return {Command} `this` command for chaining390 * @api public391 */392393 action(fn) {
30 unmodified lines
424 * @param {string} flags425 * @param {string} description426 * @param {Function|*} [fn] - custom option processing function or default vaue427 * @param {*} [defaultValue]428 * @return {Command} for chaining428 * @return {Command} `this` command for chaining429 * @api private430 */431432 _optionEx(config, flags, description, fn, defaultValue) {
109 unmodified lines
542 * @param {string} flags543 * @param {string} description544 * @param {Function|*} [fn] - custom option processing function or default vaue545 * @param {*} [defaultValue]546 * @return {Command} for chaining546 * @return {Command} `this` command for chaining547 * @api public548 */549550 option(flags, description, fn, defaultValue) {
9 unmodified lines
560 * @param {string} flags561 * @param {string} description562 * @param {Function|*} [fn] - custom option processing function or default vaue563 * @param {*} [defaultValue]564 * @return {Command} for chaining564 * @return {Command} `this` command for chaining565 * @api public566 */567568 requiredOption(flags, description, fn, defaultValue) {
16 unmodified lines
585 * Whether to store option values as properties on command object,586 * or store separately (specify false). In both cases the option values can be accessed using .opts().587 *588 * @param {boolean} value589 * @return {Command} Command for chaining589 * @return {Command} `this` command for chaining590 * @api public591 */592593 storeOptionsAsProperties(value) {
8 unmodified lines
602 * Whether to pass command to action handler,603 * or just the options (specify false).604 *605 * @param {boolean} value606 * @return {Command} Command for chaining606 * @return {Command} `this` command for chaining607 * @api public608 */609610 passCommandToAction(value) {
46 unmodified lines
657 *658 * @param {string[]} [argv] - optional, defaults to process.argv659 * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron660 * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'661 * @return {Command} for chaining661 * @return {Command} `this` command for chaining662 * @api public663 */664665 parse(argv, parseOptions) {
505 unmodified lines
1171 *1172 * @param {string} str1173 * @param {string} [flags]1174 * @param {string} [description]1175 * @return {Command | string} this for chaining1175 * @return {this | string} `this` command for chaining, or version string if no arguments1176 * @api public1177 */11781179 version(str, flags, description) {
320 unmodified lines
1500 * flags and help description for your command.1501 *1502 * @param {string} [flags]1503 * @param {string} [description]1504 * @return {Command}1504 * @return {Command} `this` command for chaining1505 * @api public1506 */15071508 helpOption(flags, description) {
204 unmodified lines