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