Skip to content

Commit

Permalink
feat: add commands alias (similar to options function) (#1850)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
OsmanAltun and bcoe committed Feb 23, 2021
1 parent 31765cb commit 00b74ad
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/yargs-factory.ts
Expand Up @@ -652,7 +652,7 @@ function Yargs(
return self;
};

self.command = function (
self.command = self.commands = function (
cmd: string | CommandHandlerDefinition | DefinitionOrCommandName[],
description?: CommandHandler['description'],
builder?: CommandBuilderDefinition | CommandBuilder,
Expand Down Expand Up @@ -1913,15 +1913,18 @@ export interface YargsInstance {
(keys: string | string[], coerceCallback: CoerceCallback): YargsInstance;
(keyCoerceCallbacks: Dictionary<CoerceCallback>): YargsInstance;
};
command(handler: CommandHandlerDefinition): YargsInstance;
command(
cmd: string | string[],
description: CommandHandler['description'],
builder?: CommandBuilderDefinition | CommandBuilder,
handler?: CommandHandlerCallback,
commandMiddleware?: Middleware[],
deprecated?: boolean
): YargsInstance;
command: {
(
cmd: string | string[],
description: CommandHandler['description'],
builder?: CommandBuilderDefinition | CommandBuilder,
handler?: CommandHandlerCallback,
commandMiddleware?: Middleware[],
deprecated?: boolean
): YargsInstance;
(handler: CommandHandlerDefinition): YargsInstance;
};
commands: YargsInstance['command'];
commandDir(dir: string, opts?: RequireDirectoryOptions): YargsInstance;
completion: {
(cmd?: string, fn?: CompletionFunction): YargsInstance;
Expand Down

0 comments on commit 00b74ad

Please sign in to comment.