1 | // Type definitions for command-line-args 5.2
|
2 | // Project: https://github.com/75lb/command-line-args
|
3 | // Definitions by: Lloyd Brookes <https://github.com/75lb>
|
4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 | // TypeScript Version: 2.2
|
6 |
|
7 | /**
|
8 | * Returns an object containing option values parsed from the command line. By default it parses the global `process.argv` array.
|
9 | * Parsing is strict by default. To be more permissive, enable `partial` or `stopAtFirstUnknown` modes.
|
10 | */
|
11 | declare function commandLineArgs(optionDefinitions: commandLineArgs.OptionDefinition[], options?: commandLineArgs.ParseOptions): commandLineArgs.CommandLineOptions;
|
12 |
|
13 | declare namespace commandLineArgs {
|
14 | interface CommandLineOptions {
|
15 | /**
|
16 | * Command-line arguments not parsed by `commandLineArgs`.
|
17 | */
|
18 | _unknown?: string[] | undefined;
|
19 | [propName: string]: any;
|
20 | }
|
21 |
|
22 | interface ParseOptions {
|
23 | /**
|
24 | * An array of strings which if present will be parsed instead of `process.argv`.
|
25 | */
|
26 | argv?: string[] | undefined;
|
27 |
|
28 | /**
|
29 | * If `true`, `commandLineArgs` will not throw on unknown options or values, instead returning them in the `_unknown` property of the output.
|
30 | */
|
31 | partial?: boolean | undefined;
|
32 |
|
33 | /**
|
34 | * If `true`, `commandLineArgs` will not throw on unknown options or values. Instead, parsing will stop at the first unknown argument
|
35 | * and the remaining arguments returned in the `_unknown` property of the output. If set, `partial: true` is implied.
|
36 | */
|
37 | stopAtFirstUnknown?: boolean | undefined;
|
38 |
|
39 | /**
|
40 | * If `true`, options with hypenated names (e.g. `move-to`) will be returned in camel-case (e.g. `moveTo`).
|
41 | */
|
42 | camelCase?: boolean | undefined;
|
43 |
|
44 | /**
|
45 | * If `true`, the case of each option name or alias parsed is insignificant. For example, `--Verbose` and
|
46 | * `--verbose` would be parsed identically, as would the aliases `-V` and `-v`. Defaults to false.
|
47 | */
|
48 | caseInsensitive?: boolean | undefined;
|
49 | }
|
50 |
|
51 | interface OptionDefinition {
|
52 | /**
|
53 | * The long option name.
|
54 | */
|
55 | name: string;
|
56 |
|
57 | /**
|
58 | * A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
|
59 | * are `String` (the default), `Number` and `Boolean` but you can use a custom function. If no option value was set you will receive `null`.
|
60 | */
|
61 | type?: ((input: string) => any) | undefined;
|
62 |
|
63 | /**
|
64 | * A getopt-style short option name. Can be any single character except a digit or hyphen.
|
65 | */
|
66 | alias?: string | undefined;
|
67 |
|
68 | /**
|
69 | * Set this flag if the option accepts multiple values. In the output, you will receive an array of values each passed through the `type` function.
|
70 | */
|
71 | multiple?: boolean | undefined;
|
72 |
|
73 | /**
|
74 | * Identical to `multiple` but with greedy parsing disabled.
|
75 | */
|
76 | lazyMultiple?: boolean | undefined;
|
77 |
|
78 | /**
|
79 | * Any values unaccounted for by an option definition will be set on the `defaultOption`. This flag is typically set
|
80 | * on the most commonly-used option to enable more concise usage.
|
81 | */
|
82 | defaultOption?: boolean | undefined;
|
83 |
|
84 | /**
|
85 | * An initial value for the option.
|
86 | */
|
87 | defaultValue?: any;
|
88 |
|
89 | /**
|
90 | * One or more group names the option belongs to.
|
91 | */
|
92 | group?: string | string[] | undefined;
|
93 | }
|
94 | }
|
95 |
|
96 | export = commandLineArgs;
|
97 |
|
\ | No newline at end of file |