1 | export default class Option {
|
2 | flags: string;
|
3 | defaultValue?: any;
|
4 | /** this option need parameter value. it is required. */
|
5 | required: boolean;
|
6 | /** this option need parameter value. it is optional. */
|
7 | optional: boolean;
|
8 | /** this option is default true. if specified this option, value is become false. */
|
9 | no: boolean;
|
10 | /** short style. e.g. -o */
|
11 | short?: string;
|
12 | /** long style. e.g. --option */
|
13 | long: string;
|
14 | /** description of this option */
|
15 | description: string;
|
16 | /**
|
17 | * class of option.
|
18 | * ```
|
19 | * cmd --path foo/bar buzz.txt
|
20 | * ↑ this one!
|
21 | * ```
|
22 | * @param flags pass '-f, --foo'(boolean) or '--foo'(boolean) or '--foo <bar>'(string[]) or '--foo [bar]'(string[]).
|
23 | * @param description
|
24 | * @param defaultValue
|
25 | * @class
|
26 | */
|
27 | constructor(flags: string, description?: string, defaultValue?: any);
|
28 | /**
|
29 | * name of this option.
|
30 | * @returns {any}
|
31 | */
|
32 | name(): string;
|
33 | /**
|
34 | * check arg is matches this option.
|
35 | * @param arg
|
36 | * @returns {boolean}
|
37 | */
|
38 | is(arg: string): boolean;
|
39 | /**
|
40 | * parse args.
|
41 | * build to opts.
|
42 | *
|
43 | * e.g. #1
|
44 | * instance member: required=true, optional=false, short=-f, long=--foo
|
45 | * method arguments: opts={}, args=["--foo", "foo!", "bar!"].
|
46 | * opts are modified to { foo: ["foo!"] } and return ["bar!"].
|
47 | *
|
48 | * e.g. #2
|
49 | * instance member: required=true, optional=false, short=-f, long=--foo
|
50 | * method arguments: opts={ foo: ["foo?"] }, args=["--foo", "foo!", "bar!"].
|
51 | * opts are modified to { foo: ["foo?", "foo!"] } and return ["bar!"].
|
52 | *
|
53 | * e.g. #3
|
54 | * instance member: required=false, optional=false, short=-f, long=--foo
|
55 | * method arguments: opts={}, args=["-f", "foo!", "bar!"].
|
56 | * opts are modified to { foo: true } and return ["foo!", "bar!"].
|
57 | *
|
58 | * @param opts
|
59 | * @param args
|
60 | * @returns {string[]}
|
61 | */
|
62 | parse(opts: any, args: string[]): string[];
|
63 | }
|