mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Update minimist definition to 1.1.3
- Add indexer to ParsedArgs - Add new options and options types
This commit is contained in:
@@ -9,8 +9,12 @@ var strArr: string[];
|
||||
var args: string[];
|
||||
var obj: minimist.ParsedArgs;
|
||||
var opts: Opts;
|
||||
var arg: any;
|
||||
|
||||
opts.string = str;
|
||||
opts.string = strArr;
|
||||
opts.boolean = true;
|
||||
opts.boolean = str;
|
||||
opts.boolean = strArr;
|
||||
opts.alias = {
|
||||
foo: strArr
|
||||
@@ -21,8 +25,19 @@ opts.default = {
|
||||
opts.default = {
|
||||
foo: num
|
||||
};
|
||||
opts.unknown = (arg: string) => {
|
||||
if(/xyz/.test(arg)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
opts.stopEarly = true;
|
||||
opts['--'] = true;
|
||||
|
||||
obj = minimist();
|
||||
obj = minimist(strArr);
|
||||
obj = minimist(strArr, opts);
|
||||
var remainingArgCount = obj._.length;
|
||||
|
||||
arg = obj['foo'];
|
||||
|
||||
16
minimist/minimist.d.ts
vendored
16
minimist/minimist.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for minimist 0.0.8
|
||||
// Type definitions for minimist 1.1.3
|
||||
// Project: https://github.com/substack/minimist
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Necroskillz <https://github.com/Necroskillz>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'minimist' {
|
||||
@@ -10,18 +10,26 @@ declare module 'minimist' {
|
||||
export interface Opts {
|
||||
// a string or array of strings argument names to always treat as strings
|
||||
// string?: string;
|
||||
string?: string[];
|
||||
string?: string|string[];
|
||||
// a string or array of strings to always treat as booleans
|
||||
// boolean?: string;
|
||||
boolean?: string[];
|
||||
boolean?: boolean|string|string[];
|
||||
// an object mapping string names to strings or arrays of string argument names to use
|
||||
// alias?: {[key:string]: string};
|
||||
alias?: {[key:string]: string[]};
|
||||
// an object mapping string argument names to default values
|
||||
default?: {[key:string]: any};
|
||||
// when true, populate argv._ with everything after the first non-option
|
||||
stopEarly?: boolean;
|
||||
// a function which is invoked with a command line parameter not defined in the opts configuration object.
|
||||
// If the function returns false, the unknown option is not added to argv
|
||||
unknown?: (arg: string) => boolean;
|
||||
// when true, populate argv._ with everything before the -- and argv['--'] with everything after the --
|
||||
'--'?: boolean;
|
||||
}
|
||||
|
||||
export interface ParsedArgs {
|
||||
[arg: string]: any;
|
||||
_: string[];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user