From c458f90930bdea33e75223de7a36cee790304f01 Mon Sep 17 00:00:00 2001 From: Drew Hays Date: Mon, 14 Mar 2016 20:43:38 -0700 Subject: [PATCH 1/3] Add some missing methods and options to yargs.d.ts Added some missing methods and options from the documentation of yargs --- yargs/yargs.d.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts index ff0132cf44..02f6a43ae8 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -21,6 +21,8 @@ declare module "yargs" { alias(shortName: string, longName: string): Argv; alias(aliases: { [shortName: string]: string }): Argv; alias(aliases: { [shortName: string]: string[] }): Argv; + + array(key: string): Argv; default(key: string, value: any): Argv; default(defaults: { [key: string]: any}): Argv; @@ -90,6 +92,8 @@ declare module "yargs" { help(): string; help(option: string, description?: string): Argv; + + env(prefix?: string): Argv; epilog(msg: string): Argv; epilogue(msg: string): Argv; @@ -102,6 +106,14 @@ declare module "yargs" { showHelp(func?: (message: string) => any): Argv; exitProcess(enabled:boolean): Argv; + + global(key: string): Argv; + global(keys: string[]): Argv; + + group(key: string, groupName: string): Argv; + group(keys: string[], groupName: string): Argv; + + nargs(key: string, count: number): Argv; /* Undocumented */ @@ -119,11 +131,13 @@ declare module "yargs" { interface Options { type?: string; + group?: string; alias?: any; demand?: any; required?: any; require?: any; default?: any; + defaultDescription?: string; boolean?: any; string?: any; count?: any; @@ -132,6 +146,15 @@ declare module "yargs" { desc?: any; requiresArg?: any; choices?:string[]; + global?: boolean; + array?: boolean; + boolean?: boolean; + config?: boolean; + count?: boolean; + string?: boolean; + number?: boolean; + normalize?: boolean; + nargs?: number; } type SyncCompletionFunction = (current: string, argv: any) => string[]; From b05e08bde03c9883997ff85331e5538d7475b0b4 Mon Sep 17 00:00:00 2001 From: Drew Hays Date: Mon, 14 Mar 2016 21:10:38 -0700 Subject: [PATCH 2/3] add tests, correct some options --- yargs/yargs-tests.ts | 38 +++++++++++++++++++++++++++++++++++++- yargs/yargs.d.ts | 11 +++++------ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 5af27636c7..61d84e9932 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -123,6 +123,12 @@ function Argv$options() { .options('f', { alias: 'file', default: '/etc/passwd', + defaultDescription: 'The /etc/passwd file', + group: 'files', + normalize: true, + global: false, + array: true, + nargs: 3 }) .argv ; @@ -134,6 +140,36 @@ function Argv$options() { ; } +function Argv$global() { + var argv = yargs + .global('foo') + .global(['bar', 'baz', 'fizz', 'buzz']) +} + +function Argv$group() { + var argv = yargs + .group('foo', 'foogroup') + .group(['bing', 'bang', 'buzz'], 'onomatopoeia') +} + +function Argv$env() { + var argv = yargs + .env('YARGS_PREFIX_') + .env() +} + +function Argv$array() { + var argv = yargs + .array('foo') + .array(['bar', 'baz']) +} + +function Argv$nargs() { + var argv = yargs + .nargs('foo', 12) + .nargs({'bing': 3, 'bang': 2, 'buzz': 4}) +} + function Argv$choices() { // example from documentation var argv = yargs @@ -241,7 +277,7 @@ function Argv$locale() { function Argv$epilogue() { var argv = yargs - .epilogue('for more information, find our manual at http://example.com'); + .epilogue('for more information, find our manual at http://example.com'); } function Argv$reset() { diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts index 02f6a43ae8..66d50d0402 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -23,6 +23,7 @@ declare module "yargs" { alias(aliases: { [shortName: string]: string[] }): Argv; array(key: string): Argv; + array(keys: string[]): Argv; default(key: string, value: any): Argv; default(defaults: { [key: string]: any}): Argv; @@ -114,6 +115,7 @@ declare module "yargs" { group(keys: string[], groupName: string): Argv; nargs(key: string, count: number): Argv; + nargs(nargs: { [key: string]: number }): Argv; /* Undocumented */ @@ -138,9 +140,9 @@ declare module "yargs" { require?: any; default?: any; defaultDescription?: string; - boolean?: any; - string?: any; - count?: any; + boolean?: boolean; + string?: boolean; + count?: boolean; describe?: any; description?: any; desc?: any; @@ -148,10 +150,7 @@ declare module "yargs" { choices?:string[]; global?: boolean; array?: boolean; - boolean?: boolean; config?: boolean; - count?: boolean; - string?: boolean; number?: boolean; normalize?: boolean; nargs?: number; From 9a317bdcc6a792134e349aa0b246f57287d66025 Mon Sep 17 00:00:00 2001 From: Drew Hays Date: Mon, 21 Mar 2016 09:02:04 -0700 Subject: [PATCH 3/3] add boolean entry for env --- yargs/yargs-tests.ts | 1 + yargs/yargs.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 61d84e9932..7eba906ec0 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -156,6 +156,7 @@ function Argv$env() { var argv = yargs .env('YARGS_PREFIX_') .env() + .env(true); } function Argv$array() { diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts index 66d50d0402..a85e0d3f0c 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -95,6 +95,7 @@ declare module "yargs" { help(option: string, description?: string): Argv; env(prefix?: string): Argv; + env(enable: boolean): Argv; epilog(msg: string): Argv; epilogue(msg: string): Argv;