diff --git a/types/yargs/index.d.ts b/types/yargs/index.d.ts index d4a47c84e7..882e8e9999 100644 --- a/types/yargs/index.d.ts +++ b/types/yargs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for yargs 10.0 +// Type definitions for yargs 11.0 // Project: https://github.com/chevex/yargs // Definitions by: Martin Poelstra // Mizunashi Mana @@ -262,9 +262,17 @@ declare namespace yargs { nargs?: number; normalize?: boolean; number?: boolean; + /** + * @deprecated since version 6.6.0 + * Use 'demandOption' instead + */ require?: boolean | string; + /** + * @deprecated since version 6.6.0 + * Use 'demandOption' instead + */ required?: boolean | string; - requiresArg?: boolean | string; + requiresArg?: boolean; skipValidation?: boolean; string?: boolean; type?: "array" | "count" | PositionalOptionsType; diff --git a/types/yargs/tsconfig.json b/types/yargs/tsconfig.json index daff5d0a1d..061816ea36 100644 --- a/types/yargs/tsconfig.json +++ b/types/yargs/tsconfig.json @@ -21,4 +21,4 @@ "index.d.ts", "yargs-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/yargs/v10/.editorconfig b/types/yargs/v10/.editorconfig new file mode 100644 index 0000000000..db9b917e06 --- /dev/null +++ b/types/yargs/v10/.editorconfig @@ -0,0 +1,5 @@ +[*.ts] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 diff --git a/types/yargs/v10/index.d.ts b/types/yargs/v10/index.d.ts new file mode 100644 index 0000000000..d4a47c84e7 --- /dev/null +++ b/types/yargs/v10/index.d.ts @@ -0,0 +1,304 @@ +// Type definitions for yargs 10.0 +// Project: https://github.com/chevex/yargs +// Definitions by: Martin Poelstra +// Mizunashi Mana +// Jeffery Grajkowski +// Jeff Kenney +// Jimi (Dimitris) Charalampidis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +// The following TSLint rules have been disabled: +// unified-signatures: Because there is useful information in the argument names of the overloaded signatures + +// Convention: +// Use 'union types' when: +// - parameter types have similar signature type (i.e. 'string | string[]') +// - parameter names have the same semantic meaning (i.e. ['command', 'commands'] , ['key', 'keys']) +// An example for not using 'union types' is the declaration of 'env' where `prefix` and `enable` parameters +// have different semantics. On the other hand, in the declaration of 'usage', a `command: string` parameter +// has the same semantic meaning with declaring an overload method by using `commands: string[]`, thus +// it's prefered to use `command: string | string[]` +// Use parameterless declaration instead of declaring all parameters optional, +// when all parameters are optional and more than one + +declare namespace yargs { + interface Argv { + (): Arguments; + (args: string[], cwd?: string): Arguments; + + alias(shortName: string | string[], longName: string | string[]): Argv; + alias(aliases: { [shortName: string]: string | string[] }): Argv; + + argv: Arguments; + + array(key: string | string[]): Argv; + + boolean(key: string | string[]): Argv; + + check(func: (argv: Arguments, aliases: { [alias: string]: string }) => any, global?: boolean): Argv; + + choices(key: string, values: Choices): Argv; + choices(choices: { [argName: string]: Choices }): Argv; + + coerce(key: string | string[], func: (arg: any) => any): Argv; + coerce(opts: { [key: string]: (arg: any) => any; }): Argv; + + command(command: string | string[], description: string, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv; + command(command: string | string[], description: string, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv; + command(command: string | string[], description: string, module: CommandModule): Argv; + command(command: string | string[], showInHelp: false, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv; + command(command: string | string[], showInHelp: false, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv; + command(command: string | string[], showInHelp: false, module: CommandModule): Argv; + command(module: CommandModule): Argv; + + // Advanced API + commandDir(dir: string, opts?: RequireDirectoryOptions): Argv; + + completion(): Argv; + completion(cmd: string, func?: AsyncCompletionFunction): Argv; + completion(cmd: string, func?: SyncCompletionFunction): Argv; + completion(cmd: string, description?: string, func?: AsyncCompletionFunction): Argv; + completion(cmd: string, description?: string, func?: SyncCompletionFunction): Argv; + + config(): Argv; + config(key: string | string[], description?: string, parseFn?: (configPath: string) => object): Argv; + config(key: string | string[], parseFn: (configPath: string) => object): Argv; + config(explicitConfigurationObject: object): Argv; + + conflicts(key: string, value: string | string[]): Argv; + conflicts(conflicts: { [key: string]: string | string[] }): Argv; + + count(key: string | string[]): Argv; + + default(key: string, value: any, description?: string): Argv; + default(defaults: { [key: string]: any }, description?: string): Argv; + + /** + * @deprecated since version 6.6.0 + * Use '.demandCommand()' or '.demandOption()' instead + */ + demand(key: string | string[], msg: string): Argv; + demand(key: string | string[], required?: boolean): Argv; + demand(positionals: number, msg: string): Argv; + demand(positionals: number, required?: boolean): Argv; + demand(positionals: number, max: number, msg?: string): Argv; + + demandOption(key: string | string[], msg?: string): Argv; + demandOption(key: string | string[], demand?: boolean): Argv; + + demandCommand(): Argv; + demandCommand(min: number, minMsg?: string): Argv; + demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv; + + describe(key: string | string[], description: string): Argv; + describe(descriptions: { [key: string]: string }): Argv; + + detectLocale(detect: boolean): Argv; + + env(): Argv; + env(prefix: string): Argv; + env(enable: boolean): Argv; + + epilog(msg: string): Argv; + + epilogue(msg: string): Argv; + + example(command: string, description: string): Argv; + + exitProcess(enabled: boolean): Argv; + + fail(func: (msg: string, err: Error) => any): Argv; + + getCompletion(args: string[], done: (completions: string[]) => void): Argv; + + global(key: string | string[]): Argv; + + group(key: string | string[], groupName: string): Argv; + + help(): Argv; + help(enableExplicit: boolean): Argv; + help(option: string, enableExplicit: boolean): Argv; + help(option: string, description?: string, enableExplicit?: boolean): Argv; + + implies(key: string, value: string | string[]): Argv; + implies(implies: { [key: string]: string | string[] }): Argv; + + locale(): string; + locale(loc: string): Argv; + + nargs(key: string, count: number): Argv; + nargs(nargs: { [key: string]: number }): Argv; + + normalize(key: string | string[]): Argv; + + number(key: string | string[]): Argv; + + option(key: string, options: Options): Argv; + option(options: { [key: string]: Options }): Argv; + + options(key: string, options: Options): Argv; + options(options: { [key: string]: Options }): Argv; + + parse(): Arguments; + parse(arg: string | string[], context?: object, parseCallback?: ParseCallback): Arguments; + + pkgConf(key: string | string[], cwd?: string): Argv; + + /** + * 'positional' should be called in a command's builder function, and is not + * available on the top-level yargs instance. If so, it will throw an error. + */ + positional(key: string, opt: PositionalOptions): Argv; + + recommendCommands(): Argv; + + /** + * @deprecated since version 6.6.0 + * Use '.demandCommand()' or '.demandOption()' instead + */ + require(key: string, msg: string): Argv; + require(key: string, required: boolean): Argv; + require(keys: number[], msg: string): Argv; + require(keys: number[], required: boolean): Argv; + require(positionals: number, required: boolean): Argv; + require(positionals: number, msg: string): Argv; + + /** + * @deprecated since version 6.6.0 + * Use '.demandCommand()' or '.demandOption()' instead + */ + required(key: string, msg: string): Argv; + required(key: string, required: boolean): Argv; + required(keys: number[], msg: string): Argv; + required(keys: number[], required: boolean): Argv; + required(positionals: number, required: boolean): Argv; + required(positionals: number, msg: string): Argv; + + requiresArg(key: string | string[]): Argv; + + /** + * @deprecated since version 6.6.0 + * Use '.global()' instead + */ + reset(): Argv; + + showCompletionScript(): Argv; + + showHelp(consoleLevel?: string): Argv; + + showHelpOnFail(enable: boolean, message?: string): Argv; + + skipValidation(key: string | string[]): Argv; + + strict(): Argv; + + string(key: string | string[]): Argv; + + // Intended to be used with '.wrap()' + terminalWidth(): number; + + updateLocale(obj: { [key: string]: string }): Argv; + + updateStrings(obj: { [key: string]: string }): Argv; + + usage(message: string): Argv; + usage(command: string | string[], description: string, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv; + usage(command: string | string[], showInHelp: boolean, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv; + usage(command: string | string[], description: string, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv; + usage(commands: string | string[], showInHelp: boolean, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv; + + version(): Argv; + version(version: string): Argv; + version(enable: boolean): Argv; + version(optionKey: string, version: string): Argv; + version(optionKey: string, description: string, version: string): Argv; + + wrap(columns: number | null): Argv; + } + + interface Arguments { + /** Non-option arguments */ + _: string[]; + /** The script name or node command */ + $0: string; + /** All remaining options */ + [argName: string]: any; + } + + interface RequireDirectoryOptions { + recurse?: boolean; + extensions?: string[]; + visit?: (commandObject: any, pathToFile?: string, filename?: string) => any; + include?: RegExp | ((pathToFile: string) => boolean); + exclude?: RegExp | ((pathToFile: string) => boolean); + } + + interface Options { + alias?: string | string[]; + array?: boolean; + boolean?: boolean; + choices?: Choices; + coerce?: (arg: any) => any; + config?: boolean; + configParser?: (configPath: string) => object; + conflicts?: string | string[] | { [key: string]: string | string[] }; + count?: boolean; + default?: any; + defaultDescription?: string; + /** + * @deprecated since version 6.6.0 + * Use 'demandOption' instead + */ + demand?: boolean | string; + demandOption?: boolean | string; + desc?: string; + describe?: string; + description?: string; + global?: boolean; + group?: string; + hidden?: boolean; + implies?: string | string[] | { [key: string]: string | string[] }; + nargs?: number; + normalize?: boolean; + number?: boolean; + require?: boolean | string; + required?: boolean | string; + requiresArg?: boolean | string; + skipValidation?: boolean; + string?: boolean; + type?: "array" | "count" | PositionalOptionsType; + } + + interface PositionalOptions { + alias?: string | string[]; + choices?: Choices; + coerce?: (arg: any) => any; + conflicts?: string | string[] | { [key: string]: string | string[] }; + default?: any; + desc?: string; + describe?: string; + description?: string; + implies?: string | string[] | { [key: string]: string | string[] }; + normalize?: boolean; + type?: PositionalOptionsType; + } + + interface CommandModule { + aliases?: string[] | string; + builder?: CommandBuilder; + command?: string[] | string; + describe?: string | false; + handler: (args: any) => void; + } + + type ParseCallback = (err: Error | undefined, argv: Arguments, output: string) => void; + type CommandBuilder = { [key: string]: Options } | ((args: Argv) => Argv); + type SyncCompletionFunction = (current: string, argv: any) => string[]; + type AsyncCompletionFunction = (current: string, argv: any, done: (completion: string[]) => void) => void; + type Choices = Array; + type PositionalOptionsType = "boolean" | "number" | "string"; +} + +declare var yargs: yargs.Argv; +export = yargs; diff --git a/types/yargs/v10/tsconfig.json b/types/yargs/v10/tsconfig.json new file mode 100644 index 0000000000..f83a62301f --- /dev/null +++ b/types/yargs/v10/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "paths": { + "yargs": [ + "yargs/v10" + ] + }, + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "yargs-tests.ts" + ] +} diff --git a/types/yargs/v10/tslint.json b/types/yargs/v10/tslint.json new file mode 100644 index 0000000000..08b1465cd6 --- /dev/null +++ b/types/yargs/v10/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "unified-signatures": false + } +} diff --git a/types/yargs/v10/yargs-tests.ts b/types/yargs/v10/yargs-tests.ts new file mode 100644 index 0000000000..43779309bf --- /dev/null +++ b/types/yargs/v10/yargs-tests.ts @@ -0,0 +1,650 @@ +/// + +import yargs = require('yargs'); + +import * as fs from 'fs'; +import * as path from 'path'; + +const stringVal = 'string'; + +// Examples taken from yargs website +// https://github.com/chevex/yargs + +// With yargs, the options be just a hash! +function xup() { + const argv = yargs.argv; + + if (argv.rif - 5 * argv.xup > 7.138) { + console.log('Plunder more riffiwobbles!'); + } else { + console.log('Drop the xupptumblers!'); + } +} + +// And non-hyphenated options too! Just use argv._! +function nonopt() { + const argv = yargs.argv; + console.log('(%d,%d)', argv.x, argv.y); + console.log(argv._); +} + +// Yargs even counts your booleans! +function count() { + const argv = yargs + .count('verbose') + .alias('v', 'verbose') + .argv; + + const VERBOSE_LEVEL: number = argv.verbose; + + function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); } + function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); } + function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); } +} + +// Tell users how to use yer options and make demands. +function divide() { + const argv = yargs + .usage('Usage: $0 -x [num] -y [num]') + .demand(['x', 'y']) + .argv; + + console.log(argv.x / argv.y); +} + +// After yer demands have been met, demand more! Ask for non-hypenated arguments! +function demand_count() { + const argv = yargs + .demand(2) + .demand(2, false) + .demand(2, 2) + .demand(2, 2, "message") + .argv; + console.dir(argv); +} + +// EVEN MORE SHIVER ME TIMBERS! +function default_singles() { + const argv = yargs + .default('x', 10) + .default('y', 10) + .argv + ; + console.log(argv.x + argv.y); +} +function default_hash() { + const argv = yargs + .default({ x: 10, y: 10 }) + .argv + ; + console.log(argv.x + argv.y); +} + +// And if you really want to get all descriptive about it... +function boolean_single() { + const argv = yargs + .boolean('v') + .argv + ; + console.dir(argv.v); + console.dir(argv._); +} +function boolean_double() { + const argv = yargs + .boolean(['x', 'y', 'z']) + .argv + ; + console.dir([argv.x, argv.y, argv.z]); + console.dir(argv._); +} + +// Yargs is here to help you... +function line_count() { + const argv = yargs + .usage('Count the lines in a file.\nUsage: $0') + .example('$0 -f', 'count the lines in the given file') + .demand('f') + .alias('f', 'file') + .describe('f', 'Load a file') + .argv + ; +} + +// Below are tests for individual methods. +// Not all methods are covered yet, and neither are all possible invocations of methods. + +function Argv$argv() { + const argv = yargs.argv; + console.log("command name: " + argv.$0); + console.log("command: " + argv._[1]); +} + +function Argv_parsing() { + const argv1 = yargs.parse(); + const argv2 = yargs(['-x', '1', '-y', '2']).argv; + const argv3 = yargs.parse(['-x', '1', '-y', '2']); + console.log(argv1.x, argv2.x, argv3.x); +} + +function Argv$options() { + const argv1 = yargs + .options('f', { + alias: 'file', + default: '/etc/passwd', + defaultDescription: 'The /etc/passwd file', + group: 'files', + normalize: true, + global: false, + array: true, + nargs: 3, + implies: 'other-arg', + conflicts: 'conflicting-arg', + }) + .argv + ; + + const argv2 = yargs + .alias('f', 'file') + .default('f', '/etc/passwd') + .argv + ; +} + +function Argv$global() { + const argv = yargs + .global('foo') + .global(['bar', 'baz', 'fizz', 'buzz']); +} + +function Argv$group() { + const argv = yargs + .group('foo', 'foogroup') + .group(['bing', 'bang', 'buzz'], 'onomatopoeia'); +} + +function Argv$env() { + const argv = yargs + .env('YARGS_PREFIX_') + .env() + .env(true); +} + +function Argv$array() { + const argv = yargs + .array('foo') + .array(['bar', 'baz']); +} + +function Argv$nargs() { + const argv = yargs + .nargs('foo', 12) + .nargs({ bing: 3, bang: 2, buzz: 4 }); +} + +function Argv$choices() { + // example from documentation + const argv = yargs + .alias('i', 'ingredient') + .describe('i', 'choose your sandwich ingredients') + .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) + .help('help') + .argv; + + yargs + .choices('i', [undefined, true, 'asdf', 'test']) + .choices({ + test: [undefined, true, 'test-value'] + }); +} + +function Argv$usage_as_default_command() { + const argv = yargs + .usage( + "$0 get", + 'make a get HTTP request', + (yargs) => { + return yargs.option('u', { + alias: 'url', + describe: 'the URL to make an HTTP request to' + }); + }, + (argv) => { + console.dir(argv.url); + } + ) + .argv; +} + +function Argv$command() { + const argv = yargs + .usage('npm ') + .command('install', 'tis a mighty fine package to install') + .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') + ) + .command("build", "arghh, build it mate", { + tag: { + default: true, + demand: true, + description: "Tag the build, mate!" + }, + publish: { + default: false, + description: "Should i publish?" + } + }) + .command({ + command: "test", + describe: "test package", + builder: { + mateys: { + demand: false + } + }, + handler: (args: any) => { + /* handle me mateys! */ + } + }) + .command("test", "test mateys", { + handler: (args: any) => { + /* handle me mateys! */ + } + }) + .help('help') + .argv; + + yargs + .command('get', 'make a get HTTP request', (yargs) => { + return yargs.option('url', { + alias: 'u', + default: 'http://yargs.js.org/' + }); + }) + .help() + .argv; + + yargs + .command( + 'get', + 'make a get HTTP request', + (yargs) => { + return yargs.option('u', { + alias: 'url', + describe: 'the URL to make an HTTP request to' + }); + }, + (argv) => { + console.dir(argv.url); + } + ) + .help() + .argv; +} + +function Argv$completion_sync() { + const argv = yargs + .completion('completion', (current, argv) => { + // 'current' is the current command being completed. + // 'argv' is the parsed arguments so far. + // simply return an array of completions. + return [ + 'foo', + 'bar' + ]; + }) + .argv; +} + +function Argv$completion_async() { + const argv = yargs + .completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => { + setTimeout(() => { + done([ + 'apple', + 'banana' + ]); + }, 500); + }) + .argv; +} + +function Argv$help() { + const argv = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") + .help() + .argv; +} + +function Argv$showHelpOnFail() { + const argv = yargs + .usage('Count the lines in a file.\nUsage: $0') + .demand('f') + .alias('f', 'file') + .describe('f', 'Load a file') + .showHelpOnFail(false, "Specify --help for available options") + .argv; +} + +function Argv$showHelp() { + const yargs1 = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); + yargs1.showHelp(); +} + +function Argv$version() { + const argv1 = yargs + .version(); + + const argv2 = yargs + .version('1.0.0'); + + const argv3 = yargs + .version('--version', '1.0.0'); + + const argv4 = yargs + .version('--version', 'Show version', '1.0.0'); + + const argv5 = yargs + .version(false); +} + +function Argv$wrap() { + const argv1 = yargs + .wrap(null); + + const argv2 = yargs + .wrap(yargs.terminalWidth()); +} + +function Argv$locale() { + const argv = yargs + .usage('./$0 - follow ye instructions true') + .option('option', { + alias: 'o', + describe: "'tis a mighty fine option", + demand: true + }) + .command('run', "Arrr, ya best be knowin' what yer doin'") + .example('$0 run foo', "shiver me timbers, here's an example for ye") + .help('help') + .wrap(70) + .locale('pirate') + .argv; +} + +function Argv$epilogue() { + const argv = yargs + .epilogue('for more information, find our manual at http://example.com'); +} + +function Argv$reset() { + const ya = yargs + .usage('$0 command') + .command('hello', 'hello command') + .command('world', 'world command') + .demand(1, 'must provide a valid command'); + const argv = yargs.argv; + const command = argv._[0]; + + if (command === 'hello') { + ya.reset() + .usage('$0 hello') + .help('h') + .example('$0 hello', 'print the hello message!') + .argv; + + console.log('hello!'); + } else if (command === 'world') { + ya.reset() + .usage('$0 world') + .help('h') + .example('$0 world', 'print the world message!') + .argv; + + console.log('world!'); + } else { + ya.showHelp(); + } +} + +// http://yargs.js.org/docs/#methods-commanddirdirectory-opts +function Argv$commandDir() { + const ya = yargs + .commandDir('.') + .argv; +} + +// http://yargs.js.org/docs/#methods-commanddirdirectory-opts +function Argv$commandDirWithOptions() { + const ya = yargs + .commandDir('.', { + recurse: false, + extensions: ['js'], + visit: (commandObject: any, pathToFile: string, filename: string) => void 0, + include: /.*\.js$/, + exclude: /.*\.spec.js$/, + }) + .argv; +} + +function Argv$normalize() { + const ya = yargs + .normalize('path') + .normalize(['user', 'group']) + .argv; +} + +// From http://yargs.js.org/docs/#methods-coercekey-fn +function Argv$coerce() { + const ya = yargs + .coerce('file', (arg: string) => { + return fs.readFileSync(arg, 'utf8'); + }) + .argv; +} +function Argv$coerces() { + const ya = yargs + .coerce({ + date: Date.parse, + json: JSON.parse + }) + .argv; +} +function Argv$coerceWithKeys() { + const ya = yargs + .coerce(['src', 'dest'], path.resolve) + .argv; +} + +// From http://yargs.js.org/docs/#methods-failfn +function Argv$fail() { + const ya = yargs + .fail((msg, err) => { + if (err) throw err; // preserve stack + console.error('You broke it!'); + console.error(msg); + process.exit(1); + }) + .argv; +} + +function Argv$implies() { + const ya = yargs + .implies('foo', 'snuh') + .implies({ + x: 'y' + }) + .argv; +} + +function Argv$count() { + const ya = yargs + .count('size') + .count(['w', 'h']) + .argv; +} + +function Argv$number() { + const ya = yargs + .number('n') + .number(['width', 'height']) + .argv; +} + +function Argv$updateStrings() { + const ya = yargs + .command('run', 'the run command') + .help('help') + .updateStrings({ + 'Commands:': 'My Commands -->\n' + }) + .wrap(null) + .argv; +} + +function Argv$default() { + const ya = yargs + .default('random', function randomValue() { + return Math.random() * 256; + }) + .argv; +} + +function Argv$configObject() { + const ya = yargs + .config({ foo: 1, bar: 2 }) + .argv; +} + +function Argv$configParseFunction() { + const ya = yargs + .config('settings', (configPath) => { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')); + }) + .config('settings', 'description', (configPath) => { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')); + }) + .argv; +} + +function Argv$helpDescriptionExplicit() { + const ya = yargs + .help('help', 'description', true) + .argv; +} + +function Argv$showHelpConsoleLevel() { + yargs.showHelp("log"); // prints to stdout using console.log() +} + +function Argv$getCompletion() { + const ya = yargs + .option('foobar', {}) + .option('foobaz', {}) + .completion() + .getCompletion(['./test.js', '--foo'], (completions) => { + console.log(completions); + }) + .argv; +} + +function Argv$pkgConf() { + const ya = yargs + .pkgConf(['key1', 'key2'], 'configFile.json') + .argv; +} + +function Argv$recommendCommands() { + const ya = yargs + .recommendCommands() + .argv; +} + +function Argv$showCompletionScript() { + const ya = yargs + .showCompletionScript() + .argv; +} + +function Argv$skipValidation() { + const ya = yargs + .skipValidation('arg1') + .skipValidation(['arg2', 'arg3']) + .argv; +} + +function Argv$commandObject() { + const options: yargs.Options = { + alias: "string", + array: true, + boolean: true, + choices: [undefined, true, "a", "b", "c"], + coerce: f => JSON.stringify(f), + config: true, + configParser: t => JSON.parse(fs.readFileSync(t, "utf8")), + count: true, + default: "myvalue", + defaultDescription: "description", + demand: true, + demandOption: true, + desc: "desc", + describe: "describe", + description: "description", + global: false, + group: "group", + nargs: 1, + normalize: false, + number: true, + requiresArg: true, + skipValidation: false, + string: true, + type: "string" + }; + const ya = yargs.command("commandname", "description", { arg: options }); +} + +function Argv$demandCommand() { + const ya = yargs + .demandCommand(1) + .demandCommand(1, 'at least 1 command required') + .demandCommand(1, 2) + .demandCommand(1, 2, 'at least 1 command required') + .demandCommand(1, 2, 'at least 1 command required', 'at most 2 commands required') + .argv; +} + +function Argv$demandOption() { + const ya = yargs + .demandOption('a') + .demandOption('a', 'a is required') + .demandOption('a', true) + .demandOption(['a', 'b']) + .demandOption(['a', 'b'], 'a and b are required') + .demandOption(['a', 'b'], true) + .argv; +} + +function Argv$conflicts() { + const ya = yargs + .conflicts('a', 'b') + .conflicts({ + a: 'b' + }) + .argv; +} + +function Argv$commandArray() { + const ya = yargs + .command(['commandName', 'commandAlias'], 'command description') + .argv; +} + +function Argv$check() { + const ya = yargs + .check((argv, aliases) => void 0) + .check((argv, aliases) => void 0, false); +}