Merge pull request #12776 from nikeee/types-2.0

Fix builder function return type
This commit is contained in:
Nathan Shively-Sanders
2016-11-23 13:10:12 -08:00
committed by GitHub
2 changed files with 33 additions and 8 deletions
+3 -4
View File
@@ -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;
+30 -4
View File
@@ -188,14 +188,13 @@ function command() {
var argv = yargs
.usage('npm <command>')
.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() {