forked from jtremback/minimist
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.d.ts
96 lines (82 loc) · 3.85 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Type definitions for minimist 1.2
// Project: https://github.com/substack/minimist
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Necroskillz <https://github.com/Necroskillz>
// kamranayub <https://github.com/kamranayub>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Return an argument object populated with the array arguments from args
*
* @param [args] An optional argument array (typically `process.argv.slice(2)`)
* @param [opts] An optional options object to customize the parsing
*/
//declare function minimist(args?: string[], opts?: minimist.Opts<{ [key: string]: any }>): minimist.ParsedArgs;
/**
* Return an argument object populated with the array arguments from args. Strongly-typed
* to be the intersect of type T with minimist.ParsedArgs.
*
* `T` The type that will be intersected with minimist.ParsedArgs to represent the argument object
*
* @param [args] An optional argument array (typically `process.argv.slice(2)`)
* @param [opts] An optional options object to customize the parsing
*/
//declare function minimist<T>(args?: string[], opts?: minimist.Opts<{ [key: string]: any }>): T & minimist.ParsedArgs;
declare function minimist<T>(args?: string[], opts?: minimist.Opts<T>): T & minimist.ParsedArgs;
/**
* Return an argument object populated with the array arguments from args. Strongly-typed
* to be the the type T which should extend minimist.ParsedArgs
*
* `T` The type that extends minimist.ParsedArgs and represents the argument object
*
* @param [args] An optional argument array (typically `process.argv.slice(2)`)
* @param [opts] An optional options object to customize the parsing
*/
declare function minimist<T extends minimist.ParsedArgs>(args?: string[], opts?: minimist.Opts<{ [key: string]: any }>): T;
declare namespace minimist {
interface Opts<T extends { [key: string]: any }> {
/**
* A string or array of strings argument names to always treat as strings
*/
string?: string | string[] | undefined;
/**
* A boolean, string or array of strings to always treat as booleans. If true will treat
* all double hyphenated arguments without equals signs as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
*/
boolean?: boolean | string | string[] | undefined;
/**
* An object mapping string names to strings or arrays of string argument names to use as aliases
*/
alias?: { [key: string]: string | string[] } | undefined;
/**
* An object mapping string argument names to default values
*/
default?: Partial<T> | undefined;
/**
* When true, populate argv._ with everything after the first non-option
*/
stopEarly?: boolean | undefined;
/**
* 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) | undefined;
/**
* When true, populate argv._ with everything before the -- and argv['--'] with everything after the --.
* Note that with -- set, parsing for arguments still stops after the `--`.
*/
'--'?: boolean | undefined;
}
interface ParsedArgs {
[arg: string]: any;
/**
* If opts['--'] is true, populated with everything after the --
*/
'--'?: string[] | undefined;
/**
* Contains all the arguments that didn't have an option associated with them
*/
_: string[];
}
}
export = minimist;