Update minimist definition to 1.1.3

- Add indexer to ParsedArgs
- Add new options and options types
This commit is contained in:
Necroskillz
2015-08-22 23:00:53 +02:00
parent 8f081073e6
commit 24e08c7acc
2 changed files with 27 additions and 4 deletions

View File

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

View File

@@ -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[];
}
}