UNPKG

1.15 kBTypeScriptView Raw
1export default class Argument {
2 /** argument name */
3 name: string;
4 /** this argument is required */
5 required: boolean;
6 /** this argument is variadic */
7 variadic: boolean;
8 /**
9 * class of argument.
10 * ```
11 * cmd --path foo/bar buzz.txt
12 * ↑ this one!
13 * ```
14 * @param arg pass '<foo>'(required) or '[foo]'(optional) or '<foo...>'(required & variadic) or '[foo...]'(optional & variadic)
15 * @class
16 */
17 constructor(arg: string);
18 /**
19 * parse args.
20 * build to opts.
21 *
22 * e.g. #1
23 * instance member: name=foo, required=true, variadic=false
24 * method arguments: opts={}, args=["foo!", "bar!"].
25 * opts are modified to { foo: "foo!" } and return ["bar!"].
26 *
27 * e.g. #2
28 * instance member: name=foo, required=false, variadic=true
29 * method arguments: opts={}, args=["foo!", "bar!"].
30 * opts are modified to { foo: ["foo!", "bar!"] } and return [].
31 *
32 * @param opts build target object
33 * @param args
34 * @returns {string[]} rest args
35 */
36 parse(opts: any, args: string[]): string[];
37}