diff --git a/yargs/index.d.ts b/yargs/index.d.ts index fa82e2490e..a1de96fbd5 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -65,11 +65,10 @@ declare namespace yargs { usage(options?: { [key: string]: Options }): Argv; command(command: string, description: string): Argv; - command(command: string, description: string, handler: (args: Argv) => void): Argv; - command(command: string, description: string, builder: (args: Argv) => Options): Argv; + command(command: string, description: string, builder: (args: Argv) => Argv): Argv; command(command: string, description: string, builder: { [optionName: string]: Options }): Argv; - command(command: string, description: string, builder: { [optionName: string]: Options }, handler: (args: Argv) => void): Argv; - command(command: string, description: string, builder: (args: Argv) => Options, handler: (args: Argv) => void): Argv; + command(command: string, description: string, builder: { [optionName: string]: Options }, handler: (args: any) => void): Argv; + command(command: string, description: string, builder: (args: Argv) => Argv, handler: (args: any) => void): Argv; command(command: string, description: string, module: CommandModule): Argv; command(module: CommandModule): Argv; diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 8fb693803a..bcdd0e5368 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -188,14 +188,13 @@ function command() { var argv = yargs .usage('npm ') .command('install', 'tis a mighty fine package to install') - .command('publish', 'shiver me timbers, should you be sharing all that', yargs => { - argv = yargs.option('f', { + .command('publish', 'shiver me timbers, should you be sharing all that', yargs => + yargs.option('f', { alias: 'force', description: 'yar, it usually be a bad idea' }) .help('help') - .argv; - }) + ) .command("build", "arghh, build it mate", { tag: { default: true, @@ -226,6 +225,33 @@ function command() { }) .help('help') .argv; + + yargs + .command('get', 'make a get HTTP request', function (yargs) { + return yargs.option('url', { + alias: 'u', + default: 'http://yargs.js.org/' + }) + }) + .help() + .argv + + yargs + .command( + 'get', + 'make a get HTTP request', + function (yargs) { + return yargs.option('u', { + alias: 'url', + describe: 'the URL to make an HTTP request to' + }) + }, + function (argv: { url: string }) { + console.dir(argv.url) + } + ) + .help() + .argv } function completion_sync() {