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
This commit is contained in:
Elisée Maurer
2016-11-01 13:56:56 +01:00
committed by Masahiro Wakame
parent f843767243
commit 674de3e822
2 changed files with 5 additions and 1 deletions

1
yargs/index.d.ts vendored
View File

@@ -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;

View File

@@ -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',