mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-29 17:08:21 +08:00
Updated yargs to 6.3.0 (#12356)
* Updated yargs to 6.3.0 * Added more tests cases for yargs. Made a couple improvements to the typings in the process.
This commit is contained in:
committed by
Masahiro Wakame
parent
f7e05529ff
commit
f71bca5275
50
yargs/index.d.ts
vendored
50
yargs/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for yargs
|
||||
// Type definitions for yargs 6.3.0
|
||||
// Project: https://github.com/chevex/yargs
|
||||
// Definitions by: Martin Poelstra <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>
|
||||
// Definitions by: Martin Poelstra <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>, Jeffery Grajkowski <https://github.com/pushplay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace yargs {
|
||||
@@ -18,12 +18,6 @@ declare namespace yargs {
|
||||
|
||||
terminalWidth(): number;
|
||||
|
||||
terminalWidth(): number;
|
||||
|
||||
terminalWidth(): number;
|
||||
|
||||
terminalWidth(): number;
|
||||
|
||||
alias(shortName: string, longName: string): Argv;
|
||||
alias(aliases: { [shortName: string]: string }): Argv;
|
||||
alias(aliases: { [shortName: string]: string[] }): Argv;
|
||||
@@ -31,8 +25,8 @@ declare namespace yargs {
|
||||
array(key: string): Argv;
|
||||
array(keys: string[]): Argv;
|
||||
|
||||
default(key: string, value: any): Argv;
|
||||
default(defaults: { [key: string]: any }): Argv;
|
||||
default(key: string, value: any, description?: string): Argv;
|
||||
default(defaults: { [key: string]: any }, description?: string): Argv;
|
||||
|
||||
demand(key: string, msg: string): Argv;
|
||||
demand(key: string, required?: boolean): Argv;
|
||||
@@ -79,6 +73,7 @@ declare namespace yargs {
|
||||
|
||||
commandDir(dir: string, opts?: RequireDirectoryOptions): Argv;
|
||||
|
||||
completion(): Argv;
|
||||
completion(cmd: string, fn?: AsyncCompletionFunction): Argv;
|
||||
completion(cmd: string, fn?: SyncCompletionFunction): Argv;
|
||||
completion(cmd: string, description?: string, fn?: AsyncCompletionFunction): Argv;
|
||||
@@ -94,18 +89,27 @@ declare namespace yargs {
|
||||
string(key: string): Argv;
|
||||
string(keys: string[]): Argv;
|
||||
|
||||
number(key: string): Argv;
|
||||
number(keys: string[]): Argv;
|
||||
|
||||
choices(choices: Object): Argv;
|
||||
choices(key: string, values: any[]): Argv;
|
||||
|
||||
config(key: string): Argv;
|
||||
config(keys: string[]): Argv;
|
||||
config(): Argv;
|
||||
config(explicitConfigurationObject: Object): Argv;
|
||||
config(key: string, description?: string, parseFn?: (configPath: string) => Object): Argv;
|
||||
config(keys: string[], description?: string, parseFn?: (configPath: string) => Object): Argv;
|
||||
config(key: string, parseFn: (configPath: string) => Object): Argv;
|
||||
config(keys: string[], parseFn: (configPath: string) => Object): Argv;
|
||||
|
||||
wrap(columns: number): Argv;
|
||||
|
||||
strict(): Argv;
|
||||
|
||||
help(): Argv;
|
||||
help(option: string, description?: string): Argv;
|
||||
help(enableExplicit: boolean): Argv;
|
||||
help(option: string, enableExplicit: boolean): Argv;
|
||||
help(option: string, description?: string, enableExplicit?: boolean): Argv;
|
||||
|
||||
env(prefix?: string): Argv;
|
||||
env(enable: boolean): Argv;
|
||||
@@ -118,7 +122,7 @@ declare namespace yargs {
|
||||
|
||||
showHelpOnFail(enable: boolean, message?: string): Argv;
|
||||
|
||||
showHelp(func?: (message: string) => any): Argv;
|
||||
showHelp(consoleLevel?: string): Argv;
|
||||
|
||||
exitProcess(enabled: boolean): Argv;
|
||||
|
||||
@@ -140,10 +144,26 @@ declare namespace yargs {
|
||||
count(key: string): Argv;
|
||||
count(keys: string[]): Argv;
|
||||
|
||||
fail(func: (msg: string, err: Error) => any): Argv;
|
||||
fail(func: (msg: string, err: Error) => any): Argv;
|
||||
|
||||
coerce<T, U>(key: string|string[], func: (arg: T) => U): Argv;
|
||||
coerce<T, U>(opts: { [key: string]: (arg: T) => U; }): Argv;
|
||||
|
||||
getCompletion(args: string[], done: (completions: string[]) => void): Argv;
|
||||
|
||||
pkgConf(key: string, cwd?: string): Argv;
|
||||
pkgConf(keys: string[], cwd?: string): Argv;
|
||||
|
||||
recommendCommands(): Argv;
|
||||
|
||||
showCompletionScript(): Argv;
|
||||
|
||||
skipValidation(key: string): Argv;
|
||||
skipValidation(keys: string[]): Argv;
|
||||
|
||||
updateLocale(obj: Object): Argv;
|
||||
|
||||
updateStrings(obj: {[key: string]: string}): Argv;
|
||||
}
|
||||
|
||||
interface RequireDirectoryOptions {
|
||||
|
||||
@@ -411,3 +411,92 @@ function Argv$count() {
|
||||
.count(['w', 'h'])
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$number() {
|
||||
var ya = yargs
|
||||
.number('n')
|
||||
.number(['width', 'height'])
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$updateStrings() {
|
||||
var ya = yargs
|
||||
.command('run', 'the run command')
|
||||
.help('help')
|
||||
.updateStrings({
|
||||
'Commands:': 'My Commands -->\n'
|
||||
})
|
||||
.wrap(null)
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$default() {
|
||||
var ya = yargs
|
||||
.default('random', function randomValue() {
|
||||
return Math.random() * 256;
|
||||
})
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$configObject() {
|
||||
var ya = yargs
|
||||
.config({foo: 1, bar: 2})
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$configParseFunction() {
|
||||
var ya = yargs
|
||||
.config('settings', function (configPath) {
|
||||
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
|
||||
})
|
||||
.config('settings', 'description', function (configPath) {
|
||||
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
|
||||
})
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$helpDescriptionExplicit() {
|
||||
var ya = yargs
|
||||
.help('help', 'description', true)
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$showHelpConsoleLevel() {
|
||||
yargs.showHelp("log"); //prints to stdout using console.log()
|
||||
}
|
||||
|
||||
function Argv$getCompletion() {
|
||||
var ya = yargs
|
||||
.option('foobar', {})
|
||||
.option('foobaz', {})
|
||||
.completion()
|
||||
.getCompletion(['./test.js', '--foo'], function (completions) {
|
||||
console.log(completions)
|
||||
})
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$pkgConf() {
|
||||
var ya = yargs
|
||||
.pkgConf(['key1', 'key2'], 'configFile.json')
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$recommendCommands() {
|
||||
var ya = yargs
|
||||
.recommendCommands()
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$showCompletionScript() {
|
||||
var ya = yargs
|
||||
.showCompletionScript()
|
||||
.argv
|
||||
}
|
||||
|
||||
function Argv$skipValidation() {
|
||||
var ya = yargs
|
||||
.skipValidation('arg1')
|
||||
.skipValidation(['arg2', 'arg3'])
|
||||
.argv
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user