From 674de3e822def41f53af3d2bb02fb5f770299d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e=20Maurer?= Date: Tue, 1 Nov 2016 13:56:56 +0100 Subject: [PATCH] Add max argument overload to yargs.demand (#12336) * Add max argument overload to yargs.demand * Add yargs.demand variant with max but without msg * yargs: Add some tests for .demand overloads * yargs: Use ? instead of separate overload definition * Merge tests fix from 640b1b735555ee4766e4f4428f54c98fd01427c8 --- yargs/index.d.ts | 1 + yargs/yargs-tests.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/yargs/index.d.ts b/yargs/index.d.ts index c3f61b59ac..8f6f7cf531 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -40,6 +40,7 @@ declare namespace yargs { demand(keys: string[], required?: boolean): Argv; demand(positionals: number, required?: boolean): Argv; demand(positionals: number, msg: string): Argv; + demand(positionals: number, max: number, msg?: string): Argv; require(key: string, msg: string): Argv; require(key: string, required: boolean): Argv; diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 8a88b8720e..02bcf0695d 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -57,6 +57,9 @@ function divide() { function demand_count() { var argv = yargs .demand(2) + .demand(2, false) + .demand(2, 2) + .demand(2, 2, "message") .argv; console.dir(argv); } @@ -224,7 +227,7 @@ function completion_sync() { function completion_async() { var argv = yargs - .completion('completion', (current, argv, done) => { + .completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => { setTimeout(function () { done([ 'apple',