Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for chainable return type #1231

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class Command extends EventEmitter {
* See .command() for creating an attached subcommand which inherits settings from its parent.
*
* @param {Command} cmd - new subcommand
* @return {Command} parent command for chaining
* @return {Command} `this` command for chaining
* @api public
*/

Expand Down Expand Up @@ -257,7 +257,7 @@ class Command extends EventEmitter {
* addHelpCommand(false); // force off
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom detais
*
* @return {Command} for chaining
* @return {Command} `this` command for chaining
* @api public
*/

Expand Down Expand Up @@ -293,7 +293,7 @@ class Command extends EventEmitter {
* For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
*
* @param {Array} args
* @return {Command} for chaining
* @return {Command} `this` command for chaining
* @api private
*/

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

Expand Down Expand Up @@ -386,7 +386,7 @@ class Command extends EventEmitter {
* });
*
* @param {Function} fn
* @return {Command} for chaining
* @return {Command} `this` command for chaining
* @api public
*/

Expand Down Expand Up @@ -425,7 +425,7 @@ class Command extends EventEmitter {
* @param {string} description
* @param {Function|*} [fn] - custom option processing function or default vaue
* @param {*} [defaultValue]
* @return {Command} for chaining
* @return {Command} `this` command for chaining
* @api private
*/

Expand Down Expand Up @@ -543,7 +543,7 @@ class Command extends EventEmitter {
* @param {string} description
* @param {Function|*} [fn] - custom option processing function or default vaue
* @param {*} [defaultValue]
* @return {Command} for chaining
* @return {Command} `this` command for chaining
* @api public
*/

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

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

Expand All @@ -603,7 +603,7 @@ class Command extends EventEmitter {
* or just the options (specify false).
*
* @param {boolean} value
* @return {Command} Command for chaining
* @return {Command} `this` command for chaining
* @api public
*/

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

Expand Down Expand Up @@ -1172,7 +1172,7 @@ class Command extends EventEmitter {
* @param {string} str
* @param {string} [flags]
* @param {string} [description]
* @return {Command | string} this for chaining
* @return {this | string} `this` command for chaining, or version string if no arguments
* @api public
*/

Expand Down Expand Up @@ -1501,7 +1501,7 @@ class Command extends EventEmitter {
*
* @param {string} [flags]
* @param {string} [description]
* @return {Command}
* @return {Command} `this` command for chaining
* @api public
*/

Expand Down
26 changes: 13 additions & 13 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ declare namespace commander {
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
* @param description - description of executable command
* @param opts - configuration options
* @returns top level command for chaining more command definitions
* @returns `this` command for chaining
*/
command(nameAndArgs: string, description: string, opts?: commander.CommandOptions): this;

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

/**
* Define argument syntax for the top-level command.
*
* @returns Command for chaining
* @returns `this` command for chaining
*/
arguments(desc: string): this;

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

Expand Down Expand Up @@ -169,7 +169,7 @@ declare namespace commander {
* // optional argument
* program.option('-c, --cheese [type]', 'add cheese [marble]');
*
* @returns Command for chaining
* @returns `this` command for chaining
*/
option(flags: string, description?: string, defaultValue?: string | boolean): this;
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
Expand All @@ -189,23 +189,23 @@ declare namespace commander {
* Whether to store option values as properties on command object,
* or store separately (specify false). In both cases the option values can be accessed using .opts().
*
* @return Command for chaining
* @returns `this` command for chaining
*/
storeOptionsAsProperties(value?: boolean): this;

/**
* Whether to pass command to action handler,
* or just the options (specify false).
*
* @return Command for chaining
* @returns `this` command for chaining
*/
passCommandToAction(value?: boolean): this;

/**
* Allow unknown options on the command line.
*
* @param [arg] if `true` or omitted, no error will be thrown for unknown options.
* @returns Command for chaining
* @returns `this` command for chaining
*/
allowUnknownOption(arg?: boolean): this;

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

Expand Down Expand Up @@ -264,7 +264,7 @@ declare namespace commander {
/**
* Set the description.
*
* @returns Command for chaining
* @returns `this` command for chaining
*/
description(str: string, argsDescription?: {[argName: string]: string}): this;
/**
Expand All @@ -275,7 +275,7 @@ declare namespace commander {
/**
* Set an alias for the command.
*
* @returns Command for chaining
* @returns `this` command for chaining
*/
alias(alias: string): this;
/**
Expand All @@ -286,7 +286,7 @@ declare namespace commander {
/**
* Set the command usage.
*
* @returns Command for chaining
* @returns `this` command for chaining
*/
usage(str: string): this;
/**
Expand All @@ -297,7 +297,7 @@ declare namespace commander {
/**
* Set the name of the command.
*
* @returns Command for chaining
* @returns `this` command for chaining
*/
name(str: string): this;
/**
Expand Down