diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 248db600be..a049af8cb3 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,37 @@ 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() + .env(true); +} + +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 +278,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 b5700e24e1..4e6ef109ec 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -21,6 +21,9 @@ 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; + array(keys: string[]): Argv; default(key: string, value: any): Argv; default(defaults: { [key: string]: any}): Argv; @@ -90,6 +93,9 @@ declare module "yargs" { help(): string; help(option: string, description?: string): Argv; + + env(prefix?: string): Argv; + env(enable: boolean): Argv; epilog(msg: string): Argv; epilogue(msg: string): Argv; @@ -102,6 +108,15 @@ 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; + nargs(nargs: { [key: string]: number }): Argv; /* Undocumented */ @@ -119,19 +134,27 @@ declare module "yargs" { interface Options { type?: string; + group?: string; alias?: any; demand?: any; required?: any; require?: any; default?: any; - boolean?: any; - string?: any; - count?: any; + defaultDescription?: string; + boolean?: boolean; + string?: boolean; + count?: boolean; describe?: any; description?: any; desc?: any; requiresArg?: any; choices?:string[]; + global?: boolean; + array?: boolean; + config?: boolean; + number?: boolean; + normalize?: boolean; + nargs?: number; } type SyncCompletionFunction = (current: string, argv: any) => string[];