1 | import { SfdxCommand } from './sfdxCommand';
|
2 | /**
|
3 | * DocOpts generator for SfdxCommands. See http://docopt.org/.
|
4 | *
|
5 | * flag.exclusive: groups elements when one of the mutually exclusive cases is a required flag: (--apple | --orange)
|
6 | * flag.exclusive: groups elements when none of the mutually exclusive cases is required (optional flags): [--apple | --orange]
|
7 | * flag.dependsOn: specifies that if one element is present, then another one is required: (--apple --orange)
|
8 | * cmd.variableArgs: produces 'name=value'
|
9 | *
|
10 | * @example
|
11 | * {
|
12 | * name: 'classnames',
|
13 | * required: true,
|
14 | * exclusive: ['suitenames']
|
15 | * ...
|
16 | * },{
|
17 | * name: 'suitenames',
|
18 | * type: 'array'
|
19 | * required: true
|
20 | * ...
|
21 | * }
|
22 | *
|
23 | * Results in:
|
24 | * Usage: <%= command.id %> (-n <string> | -s <array>)
|
25 | *
|
26 | * @example
|
27 | * {
|
28 | * name: 'classnames',
|
29 | * ...
|
30 | * excludes: ['suitenames']
|
31 | * },{
|
32 | * name: 'suitenames',
|
33 | * ...
|
34 | * }
|
35 | *
|
36 | * Results in:
|
37 | * Usage: <%= command.id %> [-n <string> | -s <string>]
|
38 | *
|
39 | * @example
|
40 | * {
|
41 | * name: 'classnames',
|
42 | * ...
|
43 | * dependsOn: ['suitenames']
|
44 | * },{
|
45 | * name: 'suitenames',
|
46 | * type: 'flag'
|
47 | * ...
|
48 | * }
|
49 | *
|
50 | * Results in:
|
51 | * Usage: <%= command.id %> (-n <string> -s)
|
52 | *
|
53 | * TODO:
|
54 | * - Support nesting, eg:
|
55 | * Usage: my_program (--either-this <and-that> | <or-this>)
|
56 | * Usage: my_program [(<one-argument> <another-argument>)]
|
57 | *
|
58 | * @param cmdDef
|
59 | */
|
60 | export declare class DocOpts<T extends typeof SfdxCommand> {
|
61 | private cmd;
|
62 | private flags;
|
63 | private flagList;
|
64 | constructor(cmd: T);
|
65 | static generate<T extends typeof SfdxCommand>(cmdDef: T): string;
|
66 | toString(): string;
|
67 | /**
|
68 | * Group flags that dependOn (and) and are exclusive (or).
|
69 | */
|
70 | private groupFlagElements;
|
71 | /**
|
72 | * Combine doc opt elements to another flag's doc opt element. This is for supporting
|
73 | * things like "and" (dependsOn) and "or" (exclusive).
|
74 | *
|
75 | * This will probably break down on complex dependsOn / exclusive flag structures.
|
76 | * For example, a flag that depends on a flag that depends on another flag.
|
77 | *
|
78 | * See tests to see what is supported.
|
79 | *
|
80 | * @param elementMap All doc opt elements.
|
81 | * @param flagName The name of the flag to combine to.
|
82 | * @param flagNames The other flag names to combine to flagName.
|
83 | * @param unionString How to combine the doc opt elements.
|
84 | */
|
85 | private combineElementsToFlag;
|
86 | /**
|
87 | * Categorize flags into required, optional, builtin opt-in, and mandatory builtin
|
88 | * flags. This is the order they should appear in the doc opts.
|
89 | *
|
90 | * For example, flags defined on the actual command should some before standard
|
91 | * fields like --json.
|
92 | */
|
93 | private categorizeFlags;
|
94 | /**
|
95 | * Generate doc opt elements for all flags.
|
96 | *
|
97 | * @param elementMap The map to add the elements to.
|
98 | * @param flagGroups The flags to generate elements for.
|
99 | */
|
100 | private generateElements;
|
101 | }
|