Skip to content

Commit 8ec3e7f

Browse files
authored
Consistently refer to returning this for chaining (not parent) (#1231)
1 parent 2c0a237 commit 8ec3e7f

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class Command extends EventEmitter {
216216
* See .command() for creating an attached subcommand which inherits settings from its parent.
217217
*
218218
* @param {Command} cmd - new subcommand
219-
* @return {Command} parent command for chaining
219+
* @return {Command} `this` command for chaining
220220
* @api public
221221
*/
222222

@@ -257,7 +257,7 @@ class Command extends EventEmitter {
257257
* addHelpCommand(false); // force off
258258
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom detais
259259
*
260-
* @return {Command} for chaining
260+
* @return {Command} `this` command for chaining
261261
* @api public
262262
*/
263263

@@ -293,7 +293,7 @@ class Command extends EventEmitter {
293293
* For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
294294
*
295295
* @param {Array} args
296-
* @return {Command} for chaining
296+
* @return {Command} `this` command for chaining
297297
* @api private
298298
*/
299299

@@ -336,7 +336,7 @@ class Command extends EventEmitter {
336336
* Register callback to use as replacement for calling process.exit.
337337
*
338338
* @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
339-
* @return {Command} for chaining
339+
* @return {Command} `this` command for chaining
340340
* @api public
341341
*/
342342

@@ -386,7 +386,7 @@ class Command extends EventEmitter {
386386
* });
387387
*
388388
* @param {Function} fn
389-
* @return {Command} for chaining
389+
* @return {Command} `this` command for chaining
390390
* @api public
391391
*/
392392

@@ -425,7 +425,7 @@ class Command extends EventEmitter {
425425
* @param {string} description
426426
* @param {Function|*} [fn] - custom option processing function or default vaue
427427
* @param {*} [defaultValue]
428-
* @return {Command} for chaining
428+
* @return {Command} `this` command for chaining
429429
* @api private
430430
*/
431431

@@ -543,7 +543,7 @@ class Command extends EventEmitter {
543543
* @param {string} description
544544
* @param {Function|*} [fn] - custom option processing function or default vaue
545545
* @param {*} [defaultValue]
546-
* @return {Command} for chaining
546+
* @return {Command} `this` command for chaining
547547
* @api public
548548
*/
549549

@@ -561,7 +561,7 @@ class Command extends EventEmitter {
561561
* @param {string} description
562562
* @param {Function|*} [fn] - custom option processing function or default vaue
563563
* @param {*} [defaultValue]
564-
* @return {Command} for chaining
564+
* @return {Command} `this` command for chaining
565565
* @api public
566566
*/
567567

@@ -586,7 +586,7 @@ class Command extends EventEmitter {
586586
* or store separately (specify false). In both cases the option values can be accessed using .opts().
587587
*
588588
* @param {boolean} value
589-
* @return {Command} Command for chaining
589+
* @return {Command} `this` command for chaining
590590
* @api public
591591
*/
592592

@@ -603,7 +603,7 @@ class Command extends EventEmitter {
603603
* or just the options (specify false).
604604
*
605605
* @param {boolean} value
606-
* @return {Command} Command for chaining
606+
* @return {Command} `this` command for chaining
607607
* @api public
608608
*/
609609

@@ -658,7 +658,7 @@ class Command extends EventEmitter {
658658
* @param {string[]} [argv] - optional, defaults to process.argv
659659
* @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
660660
* @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
661-
* @return {Command} for chaining
661+
* @return {Command} `this` command for chaining
662662
* @api public
663663
*/
664664

@@ -1172,7 +1172,7 @@ class Command extends EventEmitter {
11721172
* @param {string} str
11731173
* @param {string} [flags]
11741174
* @param {string} [description]
1175-
* @return {Command | string} this for chaining
1175+
* @return {this | string} `this` command for chaining, or version string if no arguments
11761176
* @api public
11771177
*/
11781178

@@ -1501,7 +1501,7 @@ class Command extends EventEmitter {
15011501
*
15021502
* @param {string} [flags]
15031503
* @param {string} [description]
1504-
* @return {Command}
1504+
* @return {Command} `this` command for chaining
15051505
* @api public
15061506
*/
15071507

typings/index.d.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ declare namespace commander {
8181
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
8282
* @param description - description of executable command
8383
* @param opts - configuration options
84-
* @returns top level command for chaining more command definitions
84+
* @returns `this` command for chaining
8585
*/
8686
command(nameAndArgs: string, description: string, opts?: commander.CommandOptions): this;
8787

@@ -98,14 +98,14 @@ declare namespace commander {
9898
*
9999
* See .command() for creating an attached subcommand which inherits settings from its parent.
100100
*
101-
* @returns parent command for chaining
101+
* @returns `this` command for chaining
102102
*/
103103
addCommand(cmd: Command): this;
104104

105105
/**
106106
* Define argument syntax for command.
107107
*
108-
* @returns Command for chaining
108+
* @returns `this` command for chaining
109109
*/
110110
arguments(desc: string): this;
111111

@@ -125,7 +125,7 @@ declare namespace commander {
125125
* // output help here
126126
* });
127127
*
128-
* @returns Command for chaining
128+
* @returns `this` command for chaining
129129
*/
130130
action(fn: (...args: any[]) => void | Promise<void>): this;
131131

@@ -169,7 +169,7 @@ declare namespace commander {
169169
* // optional argument
170170
* program.option('-c, --cheese [type]', 'add cheese [marble]');
171171
*
172-
* @returns Command for chaining
172+
* @returns `this` command for chaining
173173
*/
174174
option(flags: string, description?: string, defaultValue?: string | boolean): this;
175175
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
@@ -189,23 +189,23 @@ declare namespace commander {
189189
* Whether to store option values as properties on command object,
190190
* or store separately (specify false). In both cases the option values can be accessed using .opts().
191191
*
192-
* @return Command for chaining
192+
* @returns `this` command for chaining
193193
*/
194194
storeOptionsAsProperties(value?: boolean): this;
195195

196196
/**
197197
* Whether to pass command to action handler,
198198
* or just the options (specify false).
199199
*
200-
* @return Command for chaining
200+
* @returns `this` command for chaining
201201
*/
202202
passCommandToAction(value?: boolean): this;
203203

204204
/**
205205
* Allow unknown options on the command line.
206206
*
207207
* @param [arg] if `true` or omitted, no error will be thrown for unknown options.
208-
* @returns Command for chaining
208+
* @returns `this` command for chaining
209209
*/
210210
allowUnknownOption(arg?: boolean): this;
211211

@@ -221,7 +221,7 @@ declare namespace commander {
221221
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
222222
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
223223
*
224-
* @returns Command for chaining
224+
* @returns `this` command for chaining
225225
*/
226226
parse(argv?: string[], options?: ParseOptions): this;
227227

@@ -264,7 +264,7 @@ declare namespace commander {
264264
/**
265265
* Set the description.
266266
*
267-
* @returns Command for chaining
267+
* @returns `this` command for chaining
268268
*/
269269
description(str: string, argsDescription?: {[argName: string]: string}): this;
270270
/**
@@ -275,7 +275,7 @@ declare namespace commander {
275275
/**
276276
* Set an alias for the command.
277277
*
278-
* @returns Command for chaining
278+
* @returns `this` command for chaining
279279
*/
280280
alias(alias: string): this;
281281
/**
@@ -286,7 +286,7 @@ declare namespace commander {
286286
/**
287287
* Set the command usage.
288288
*
289-
* @returns Command for chaining
289+
* @returns `this` command for chaining
290290
*/
291291
usage(str: string): this;
292292
/**
@@ -297,7 +297,7 @@ declare namespace commander {
297297
/**
298298
* Set the name of the command.
299299
*
300-
* @returns Command for chaining
300+
* @returns `this` command for chaining
301301
*/
302302
name(str: string): this;
303303
/**

0 commit comments

Comments
 (0)