Skip to content

Commit

Permalink
fix(yargs): add missing command(module) signature (#1707)
Browse files Browse the repository at this point in the history
Close #1704
  • Loading branch information
mleguen committed Aug 6, 2020
1 parent a552990 commit 0f81024
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/command.ts
Expand Up @@ -465,10 +465,9 @@ export interface CommandInstance {
callerFile: string,
opts?: RequireDirectoryOptions<any>
): void
addHandler (handler: CommandHandlerDefinition): void
addHandler (
cmd: string | string[],
description: CommandHandler['description'],
cmd: string | string[] | CommandHandlerDefinition,
description?: CommandHandler['description'],
builder?: CommandBuilderDefinition | CommandBuilder,
handler?: CommandHandlerCallback,
commandMiddleware?: Middleware[],
Expand Down
12 changes: 10 additions & 2 deletions lib/yargs.ts
@@ -1,4 +1,4 @@
import { CommandInstance, CommandHandler, CommandBuilderDefinition, CommandBuilder, CommandHandlerCallback, FinishCommandHandler, command as Command } from './command'
import { CommandInstance, CommandHandler, CommandBuilderDefinition, CommandBuilder, CommandHandlerCallback, FinishCommandHandler, command as Command, CommandHandlerDefinition } from './command'
import { Dictionary, assertNotStrictEqual, KeyOf, DictionaryKeyof, ValueOf, objectKeys, assertSingleKey } from './common-types'
import {
Arguments as ParserArguments,
Expand Down Expand Up @@ -463,7 +463,14 @@ export function Yargs (processArgs: string | string[] = [], cwd = process.cwd(),
return self
}

self.command = function (cmd, description, builder, handler, middlewares, deprecated) {
self.command = function (
cmd: string | string[] | CommandHandlerDefinition,
description?: CommandHandler['description'],
builder?: CommandBuilderDefinition | CommandBuilder,
handler?: CommandHandlerCallback,
middlewares?: Middleware[],
deprecated?: boolean
) {
argsert('<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]', [cmd, description, builder, handler, middlewares, deprecated], arguments.length)
command.addHandler(cmd, description, builder, handler, middlewares, deprecated)
return self
Expand Down Expand Up @@ -1446,6 +1453,7 @@ export interface YargsInstance {
(keys: string | string[], coerceCallback: CoerceCallback): YargsInstance
(keyCoerceCallbacks: Dictionary<CoerceCallback>): YargsInstance
}
command (handler: CommandHandlerDefinition): YargsInstance
command (
cmd: string | string[],
description: CommandHandler['description'],
Expand Down

0 comments on commit 0f81024

Please sign in to comment.