xref: /openbsd-src/gnu/llvm/lldb/source/Commands/OptionsBase.td (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1061da546Spatrick
2061da546Spatrick// The fields below describe how the fields of `OptionDefinition` struct are
3061da546Spatrick// initialized by different definitions in the Options.td and this file.
4061da546Spatrick////////////////////////////////////////////////////////////////////////////////
5061da546Spatrick// Field: usage_mask
6061da546Spatrick// Default value: LLDB_OPT_SET_ALL (Option allowed in all groups)
7061da546Spatrick// Set by:
8061da546Spatrick//  - `Group`: Sets a single group to this option.
9061da546Spatrick//             Example: def foo : Option<"foo", "f">, Group<1>;
10061da546Spatrick//  - `Groups`: Sets a given list of group numbers.
11061da546Spatrick//              Example: def foo : Option<"foo", "f">, Groups<[1,4,6]>;
12061da546Spatrick//  - `GroupRange`: Sets an interval of groups. Start and end are inclusive.
13061da546Spatrick//                  Example: def foo : Option<"foo", "f">, GroupRange<1, 4>;
14061da546Spatrick//                           Sets group 1, 2, 3, 4 for the option.
15061da546Spatrick////////////////////////////////////////////////////////////////////////////////
16061da546Spatrick// Field: required
17061da546Spatrick// Default value: false (Not required)
18061da546Spatrick// Set by:
19061da546Spatrick//   - `Required`: Marks the option as required.
20061da546Spatrick//              Example: def foo : Option<"foo", "f">, Required;
21061da546Spatrick////////////////////////////////////////////////////////////////////////////////
22061da546Spatrick// Field: long_option
23061da546Spatrick// Default value: not available (has to be defined in Option)
24061da546Spatrick// Set by:
25061da546Spatrick//   - `Option` constructor: Already set by constructor.
26061da546Spatrick//                           Example: def foo : Option<"long-option", "l">
27061da546Spatrick//                                                           ^
28061da546Spatrick//                                                    long option value
29061da546Spatrick////////////////////////////////////////////////////////////////////////////////
30061da546Spatrick// Field: short_option
31061da546Spatrick// Default value: not available (has to be defined in Option)
32061da546Spatrick// Set by:
33061da546Spatrick//   - `Option` constructor: Already set by constructor.
34061da546Spatrick//                           Example: def foo : Option<"long-option", "l">
35061da546Spatrick//                                                                     ^
36061da546Spatrick//                                                                short option
37061da546Spatrick////////////////////////////////////////////////////////////////////////////////
38061da546Spatrick// Field: option_has_arg
39061da546Spatrick// Default value: OptionParser::eNoArgument (No argument allowed)
40061da546Spatrick// Set by:
41061da546Spatrick//  - `OptionalArg`: Sets the argument type and marks it as optional.
42061da546Spatrick//  - `Arg`: Sets the argument type and marks it as required.
43061da546Spatrick//  - `EnumArg`: Sets the argument type to an enum and marks it as required.
44061da546Spatrick//  - `OptionalEnumArg`: Same as EnumArg but marks it as optional.
45061da546Spatrick// See argument_type field for more info.
46061da546Spatrick////////////////////////////////////////////////////////////////////////////////
47061da546Spatrick// Field: validator
48061da546Spatrick// Default value: 0 (No validator for option)
49061da546Spatrick// Set by:
50061da546Spatrick//  - `Validator`: Sets the value to a given validator (which has to exist in
51061da546Spatrick//                 the surrounding code.
52061da546Spatrick////////////////////////////////////////////////////////////////////////////////
53061da546Spatrick// Field: enum_values
54061da546Spatrick// Default value: {} (No enum associated with this option)
55061da546Spatrick// Set by:
56061da546Spatrick//  - `OptionalEnumArg`:
57061da546Spatrick//  - `EnumArg`: Sets the argument type and assigns it a enum holding the valid
58061da546Spatrick//               values. The enum needs to be a variable in the including code.
59061da546Spatrick//               Marks the option as required (see option_has_arg).
60061da546Spatrick//               Example: def foo : Option<"foo", "f">,
61061da546Spatrick//                          EnumArg<"SortOrder",
62061da546Spatrick//                          "OptionEnumValues(g_sort_option_enumeration)">;
63061da546Spatrick////////////////////////////////////////////////////////////////////////////////
64061da546Spatrick// Field: completion_type
65061da546Spatrick// Default value: CommandCompletions::eNoCompletion (no tab completion)
66061da546Spatrick// Set by:
67061da546Spatrick//  - `Completion`: Gives the option a single completion kind.
68061da546Spatrick//                  Example: def foo : Option<"foo", "f">,
69061da546Spatrick//                             Completion<"DiskFile">;
70061da546Spatrick//                           Sets the completion to eDiskFileCompletion
71061da546Spatrick//
72061da546Spatrick//  - `Completions`: Sets a given kinds of completions.
73061da546Spatrick//                   Example: def foo : Option<"foo", "f">,
74061da546Spatrick//                              Completions<["DiskFile", "DiskDirectory"]>;
75061da546Spatrick//                            Sets the completion to
76061da546Spatrick//                            `eDiskFileCompletion | eDiskDirectoryCompletion`.
77061da546Spatrick////////////////////////////////////////////////////////////////////////////////
78061da546Spatrick// Field: argument_type
79061da546Spatrick// Default value: eArgTypeNone
80061da546Spatrick// Set by:
81061da546Spatrick//  - `OptionalArg`: Sets the argument type and marks it as optional.
82061da546Spatrick//                   Example: def foo : Option<"foo", "f">, OptionalArg<"Pid">;
83061da546Spatrick//                   Sets the argument type to eArgTypePid and marks option as
84061da546Spatrick//                   optional (see option_has_arg).
85061da546Spatrick//  - `Arg`: Sets the argument type and marks it as required.
86061da546Spatrick//           Example: def foo : Option<"foo", "f">, Arg<"Pid">;
87061da546Spatrick//                    Sets the argument type to eArgTypePid and marks option as
88061da546Spatrick//                    required (see option_has_arg).
89061da546Spatrick//  - `OptionalEnumArg`:
90061da546Spatrick//  - `EnumArg`: Sets the argument type and assigns it a enum holding the valid
91061da546Spatrick//               values. The enum needs to be a variable in the including code.
92061da546Spatrick//               Marks the option as required (see option_has_arg).
93061da546Spatrick//               Example: def foo : Option<"foo", "f">,
94061da546Spatrick//                          EnumArg<"SortOrder",
95061da546Spatrick//                          "OptionEnumValues(g_sort_option_enumeration)">;
96061da546Spatrick//               Use `OptionalEnumArg` for having an option enum argument.
97061da546Spatrick////////////////////////////////////////////////////////////////////////////////
98061da546Spatrick// Field: usage_text
99061da546Spatrick// Default value: ""
100061da546Spatrick// Set by:
101061da546Spatrick//  - `Desc`: Sets the description for the given option.
102061da546Spatrick//            Example: def foo : Option<"foo", "f">, Desc<"does nothing.">;
103061da546Spatrick//                     Sets the description to "does nothing.".
104061da546Spatrick
105061da546Spatrick// Base class for all options.
106061da546Spatrickclass Option<string fullname, string shortname> {
107061da546Spatrick  string FullName = fullname;
108061da546Spatrick  string ShortName = shortname;
109061da546Spatrick  // The full associated command/subcommand such as "settings set".
110061da546Spatrick  string Command;
111061da546Spatrick}
112061da546Spatrick
113061da546Spatrick// Moves the option into a list of option groups.
114061da546Spatrickclass Groups<list<int> groups> {
115061da546Spatrick  list<int> Groups = groups;
116061da546Spatrick}
117061da546Spatrick
118061da546Spatrick// Moves the option in all option groups in a range.
119061da546Spatrick// Start and end values are inclusive.
120061da546Spatrickclass GroupRange<int start, int end> {
121061da546Spatrick  int GroupStart = start;
122061da546Spatrick  int GroupEnd = end;
123061da546Spatrick}
124061da546Spatrick// Moves the option in a single option group.
125061da546Spatrickclass Group<int group> {
126061da546Spatrick  int GroupStart = group;
127061da546Spatrick  int GroupEnd = group;
128061da546Spatrick}
129061da546Spatrick
130061da546Spatrick// Sets the description for the option that should be
131061da546Spatrick// displayed to the user.
132061da546Spatrickclass Desc<string description> {
133061da546Spatrick  string Description = description;
134061da546Spatrick}
135061da546Spatrick
136061da546Spatrick// Marks the option as required when calling the
137061da546Spatrick// associated command.
138061da546Spatrickclass Required {
139061da546Spatrick  bit Required = 1;
140061da546Spatrick}
141061da546Spatrick
142061da546Spatrick// Gives the option an optional argument.
143061da546Spatrickclass OptionalArg<string type> {
144061da546Spatrick  string ArgType = type;
145061da546Spatrick  bit OptionalArg = 1;
146061da546Spatrick}
147061da546Spatrick
148061da546Spatrick// Gives the option an required argument.
149061da546Spatrickclass Arg<string type> {
150061da546Spatrick  string ArgType = type;
151061da546Spatrick}
152061da546Spatrick
153061da546Spatrick// Gives the option an required argument.
154*f6aab3d8Srobertclass EnumArg<string type> {
155061da546Spatrick  string ArgType = type;
156061da546Spatrick}
157061da546Spatrick
158061da546Spatrick// Gives the option an required argument.
159*f6aab3d8Srobertclass OptionalEnumArg<string type> {
160061da546Spatrick  string ArgType = type;
161061da546Spatrick  bit OptionalArg = 1;
162061da546Spatrick}
163061da546Spatrick
164061da546Spatrick// Sets the available completions for the given option.
165061da546Spatrickclass Completions<list<string> completions> {
166061da546Spatrick  list<string> Completions = completions;
167061da546Spatrick}
168061da546Spatrick// Sets a single completion for the given option.
169061da546Spatrickclass Completion<string completion> {
170061da546Spatrick  list<string> Completions = [completion];
171061da546Spatrick}
172061da546Spatrick
173061da546Spatrick// Sets the validator for a given option.
174061da546Spatrickclass Validator<string validator> {
175061da546Spatrick  string Validator = validator;
176061da546Spatrick}
177