@optique/core 1.0.0-dev.431 → 1.0.0-dev.434
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/facade.cjs +203 -180
- package/dist/facade.d.cts +76 -184
- package/dist/facade.d.ts +76 -184
- package/dist/facade.js +203 -180
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/facade.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Message } from "./message.cjs";
|
|
2
|
+
import { HiddenVisibility, OptionName } from "./usage.cjs";
|
|
2
3
|
import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.cjs";
|
|
3
4
|
import { InferMode, InferValue, Mode, ModeValue, Parser } from "./parser.cjs";
|
|
4
5
|
import { ShellCompletion } from "./completion.cjs";
|
|
@@ -8,101 +9,55 @@ import { Program } from "./program.cjs";
|
|
|
8
9
|
//#region src/facade.d.ts
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Sub-configuration for a meta command's command form.
|
|
12
13
|
*
|
|
13
|
-
* @since 0.
|
|
14
|
-
*/
|
|
15
|
-
type CompletionName = "singular" | "plural" | "both";
|
|
16
|
-
/**
|
|
17
|
-
* Visibility policy for completion entries in help and usage output.
|
|
18
|
-
*
|
|
19
|
-
* @since 0.10.0
|
|
14
|
+
* @since 1.0.0
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
|
-
type CompletionConfigBase<THelp> = {
|
|
16
|
+
interface CommandSubConfig {
|
|
23
17
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* - `"both"`: Both `completion` subcommand and `--completion` option
|
|
28
|
-
* are available
|
|
29
|
-
*
|
|
30
|
-
* @default `"both"`
|
|
18
|
+
* Command names. The first element is the display name shown in help
|
|
19
|
+
* output; additional elements are hidden aliases that are accepted but
|
|
20
|
+
* not shown.
|
|
31
21
|
*/
|
|
32
|
-
readonly
|
|
22
|
+
readonly names?: readonly [string, ...string[]];
|
|
33
23
|
/**
|
|
34
|
-
* Group label for the
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @since 0.10.0
|
|
24
|
+
* Group label for the command in help output. When specified, the command
|
|
25
|
+
* appears under a titled section with this name instead of alongside
|
|
26
|
+
* user-defined commands.
|
|
39
27
|
*/
|
|
40
28
|
readonly group?: string;
|
|
41
29
|
/**
|
|
42
|
-
*
|
|
43
|
-
* `pwsh`, and `zsh`. You can provide additional custom shell completions
|
|
44
|
-
* or override the defaults.
|
|
30
|
+
* Granular visibility control.
|
|
45
31
|
*
|
|
46
|
-
*
|
|
32
|
+
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
33
|
+
* - `"usage"`: Hidden from usage lines only.
|
|
34
|
+
* - `"doc"`: Hidden from documentation only.
|
|
47
35
|
*/
|
|
48
|
-
readonly
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* @default Returns `void` when completion is shown.
|
|
57
|
-
*/
|
|
58
|
-
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
59
|
-
} | {
|
|
36
|
+
readonly hidden?: HiddenVisibility;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sub-configuration for a meta command's option form.
|
|
40
|
+
*
|
|
41
|
+
* @since 1.0.0
|
|
42
|
+
*/
|
|
43
|
+
interface OptionSubConfig {
|
|
60
44
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* - `"option"`: Only the `--completion` option is available
|
|
45
|
+
* Option names (all shown in help, e.g., `"-h"`, `"--help"`).
|
|
64
46
|
*/
|
|
65
|
-
readonly
|
|
66
|
-
/** @since 0.10.0 */
|
|
67
|
-
readonly group?: never;
|
|
68
|
-
/** @default `{ bash, fish, nu, pwsh, zsh }` */
|
|
69
|
-
readonly shells?: Record<string, ShellCompletion>;
|
|
70
|
-
/** @default Returns `void` when completion is shown. */
|
|
71
|
-
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
72
|
-
};
|
|
73
|
-
type CompletionConfigBoth<THelp> = CompletionConfigBase<THelp> & {
|
|
47
|
+
readonly names?: readonly [OptionName, ...OptionName[]];
|
|
74
48
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* - `"singular"`: Use `completion` / `--completion`
|
|
78
|
-
* - `"plural"`: Use `completions` / `--completions`
|
|
79
|
-
* - `"both"`: Use both singular and plural forms
|
|
80
|
-
*
|
|
81
|
-
* @default `"both"`
|
|
49
|
+
* Group label for the option in help output.
|
|
82
50
|
*/
|
|
83
|
-
readonly
|
|
51
|
+
readonly group?: string;
|
|
84
52
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* - `"both"`: Show both singular and plural entries
|
|
88
|
-
* - `"singular"`: Show only singular entries
|
|
89
|
-
* - `"plural"`: Show only plural entries
|
|
90
|
-
* - `"none"`: Hide completion entries from help and usage
|
|
53
|
+
* Granular visibility control.
|
|
91
54
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
55
|
+
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
56
|
+
* - `"usage"`: Hidden from usage lines only.
|
|
57
|
+
* - `"doc"`: Hidden from documentation only.
|
|
94
58
|
*/
|
|
95
|
-
readonly
|
|
96
|
-
}
|
|
97
|
-
type CompletionConfigSingular<THelp> = CompletionConfigBase<THelp> & {
|
|
98
|
-
readonly name: "singular";
|
|
99
|
-
readonly helpVisibility?: "singular" | "none";
|
|
100
|
-
};
|
|
101
|
-
type CompletionConfigPlural<THelp> = CompletionConfigBase<THelp> & {
|
|
102
|
-
readonly name: "plural";
|
|
103
|
-
readonly helpVisibility?: "plural" | "none";
|
|
104
|
-
};
|
|
105
|
-
type CompletionConfig<THelp> = CompletionConfigBoth<THelp> | CompletionConfigSingular<THelp> | CompletionConfigPlural<THelp>;
|
|
59
|
+
readonly hidden?: HiddenVisibility;
|
|
60
|
+
}
|
|
106
61
|
/**
|
|
107
62
|
* Configuration options for the {@link run} function.
|
|
108
63
|
*
|
|
@@ -163,125 +118,62 @@ interface RunOptions<THelp, TError> {
|
|
|
163
118
|
*/
|
|
164
119
|
readonly sectionOrder?: (a: DocSection, b: DocSection) => number;
|
|
165
120
|
/**
|
|
166
|
-
* Help configuration.
|
|
121
|
+
* Help configuration. When provided, enables help functionality.
|
|
122
|
+
* At least one of `command` or `option` must be specified.
|
|
123
|
+
*
|
|
124
|
+
* @since 1.0.0
|
|
167
125
|
*/
|
|
168
126
|
readonly help?: {
|
|
169
|
-
/**
|
|
170
|
-
* Determines how help is made available:
|
|
171
|
-
*
|
|
172
|
-
* - `"command"`: Only the `help` subcommand is available
|
|
173
|
-
* - `"both"`: Both `help` subcommand and `--help` option are available
|
|
174
|
-
*
|
|
175
|
-
* @default `"option"`
|
|
176
|
-
*/
|
|
177
|
-
readonly mode: "command" | "both";
|
|
178
|
-
/**
|
|
179
|
-
* Group label for the help command in help output. When specified,
|
|
180
|
-
* the help command appears under a titled section with this name
|
|
181
|
-
* instead of alongside user-defined commands.
|
|
182
|
-
*
|
|
183
|
-
* @since 0.10.0
|
|
184
|
-
*/
|
|
185
|
-
readonly group?: string;
|
|
186
|
-
/**
|
|
187
|
-
* Callback function invoked when help is requested. The function can
|
|
188
|
-
* optionally receive an exit code parameter.
|
|
189
|
-
*
|
|
190
|
-
* You usually want to pass `process.exit` on Node.js or Bun and
|
|
191
|
-
* `Deno.exit` on Deno to this option.
|
|
192
|
-
*
|
|
193
|
-
* @default Returns `void` when help is shown.
|
|
194
|
-
*/
|
|
127
|
+
/** Callback invoked when help is requested. */
|
|
195
128
|
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
129
|
+
} & ({
|
|
130
|
+
readonly command: true | CommandSubConfig;
|
|
131
|
+
readonly option?: true | OptionSubConfig;
|
|
196
132
|
} | {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* - `"option"`: Only the `--help` option is available
|
|
201
|
-
*
|
|
202
|
-
* @default `"option"`
|
|
203
|
-
*/
|
|
204
|
-
readonly mode?: "option";
|
|
205
|
-
/** @since 0.10.0 */
|
|
206
|
-
readonly group?: never;
|
|
207
|
-
/**
|
|
208
|
-
* Callback function invoked when help is requested. The function can
|
|
209
|
-
* optionally receive an exit code parameter.
|
|
210
|
-
*
|
|
211
|
-
* You usually want to pass `process.exit` on Node.js or Bun and
|
|
212
|
-
* `Deno.exit` on Deno to this option.
|
|
213
|
-
*
|
|
214
|
-
* @default Returns `void` when help is shown.
|
|
215
|
-
*/
|
|
216
|
-
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
217
|
-
};
|
|
133
|
+
readonly option: true | OptionSubConfig;
|
|
134
|
+
readonly command?: true | CommandSubConfig;
|
|
135
|
+
});
|
|
218
136
|
/**
|
|
219
|
-
* Version configuration.
|
|
137
|
+
* Version configuration. When provided, enables version functionality.
|
|
138
|
+
* At least one of `command` or `option` must be specified.
|
|
139
|
+
*
|
|
140
|
+
* @since 1.0.0
|
|
220
141
|
*/
|
|
221
142
|
readonly version?: {
|
|
222
|
-
/**
|
|
223
|
-
* Determines how version is made available:
|
|
224
|
-
*
|
|
225
|
-
* - `"command"`: Only the `version` subcommand is available
|
|
226
|
-
* - `"both"`: Both `version` subcommand and `--version` option are
|
|
227
|
-
* available
|
|
228
|
-
*
|
|
229
|
-
* @default `"option"`
|
|
230
|
-
*/
|
|
231
|
-
readonly mode: "command" | "both";
|
|
232
|
-
/**
|
|
233
|
-
* The version string to display when version is requested.
|
|
234
|
-
*/
|
|
143
|
+
/** The version string to display when version is requested. */
|
|
235
144
|
readonly value: string;
|
|
236
|
-
/**
|
|
237
|
-
* Group label for the version command in help output. When specified,
|
|
238
|
-
* the version command appears under a titled section with this name
|
|
239
|
-
* instead of alongside user-defined commands.
|
|
240
|
-
*
|
|
241
|
-
* @since 0.10.0
|
|
242
|
-
*/
|
|
243
|
-
readonly group?: string;
|
|
244
|
-
/**
|
|
245
|
-
* Callback function invoked when version is requested. The function can
|
|
246
|
-
* optionally receive an exit code parameter.
|
|
247
|
-
*
|
|
248
|
-
* You usually want to pass `process.exit` on Node.js or Bun and
|
|
249
|
-
* `Deno.exit` on Deno to this option.
|
|
250
|
-
*
|
|
251
|
-
* @default Returns `void` when version is shown.
|
|
252
|
-
*/
|
|
145
|
+
/** Callback invoked when version is requested. */
|
|
253
146
|
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
147
|
+
} & ({
|
|
148
|
+
readonly command: true | CommandSubConfig;
|
|
149
|
+
readonly option?: true | OptionSubConfig;
|
|
254
150
|
} | {
|
|
151
|
+
readonly option: true | OptionSubConfig;
|
|
152
|
+
readonly command?: true | CommandSubConfig;
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* Completion configuration. When provided, enables shell completion.
|
|
156
|
+
* At least one of `command` or `option` must be specified.
|
|
157
|
+
*
|
|
158
|
+
* @since 1.0.0
|
|
159
|
+
*/
|
|
160
|
+
readonly completion?: {
|
|
255
161
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* - `"option"`: Only the `--version` option is available
|
|
259
|
-
*
|
|
260
|
-
* @default `"option"`
|
|
261
|
-
*/
|
|
262
|
-
readonly mode?: "option";
|
|
263
|
-
/**
|
|
264
|
-
* The version string to display when version is requested.
|
|
265
|
-
*/
|
|
266
|
-
readonly value: string;
|
|
267
|
-
/** @since 0.10.0 */
|
|
268
|
-
readonly group?: never;
|
|
269
|
-
/**
|
|
270
|
-
* Callback function invoked when version is requested. The function can
|
|
271
|
-
* optionally receive an exit code parameter.
|
|
162
|
+
* Available shell completions. By default, includes `bash`, `fish`,
|
|
163
|
+
* `nu`, `pwsh`, and `zsh`.
|
|
272
164
|
*
|
|
273
|
-
*
|
|
274
|
-
* `Deno.exit` on Deno to this option.
|
|
275
|
-
*
|
|
276
|
-
* @default Returns `void` when version is shown.
|
|
165
|
+
* @default `{ bash, fish, nu, pwsh, zsh }`
|
|
277
166
|
*/
|
|
167
|
+
readonly shells?: Record<string, ShellCompletion>;
|
|
168
|
+
/** Callback invoked when completion is requested. */
|
|
278
169
|
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
170
|
+
} & ({
|
|
171
|
+
readonly command: true | CommandSubConfig;
|
|
172
|
+
readonly option?: true | OptionSubConfig;
|
|
173
|
+
} | {
|
|
174
|
+
readonly option: true | OptionSubConfig;
|
|
175
|
+
readonly command?: true | CommandSubConfig;
|
|
176
|
+
});
|
|
285
177
|
/**
|
|
286
178
|
* What to display above error messages:
|
|
287
179
|
* - `"usage"`: Show usage information
|
|
@@ -559,4 +451,4 @@ declare function runWithSync<TParser extends Parser<"sync", unknown, unknown>, T
|
|
|
559
451
|
*/
|
|
560
452
|
declare function runWithAsync<TParser extends Parser<Mode, unknown, unknown>, TContexts extends readonly SourceContext<unknown>[], THelp = void, TError = never>(parser: TParser, programName: string, contexts: TContexts, options: RunWithOptions<THelp, TError> & ExtractRequiredOptions<TContexts, InferValue<TParser>>): Promise<InferValue<TParser>>;
|
|
561
453
|
//#endregion
|
|
562
|
-
export {
|
|
454
|
+
export { CommandSubConfig, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
package/dist/facade.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Message } from "./message.js";
|
|
2
|
+
import { HiddenVisibility, OptionName } from "./usage.js";
|
|
2
3
|
import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.js";
|
|
3
4
|
import { InferMode, InferValue, Mode, ModeValue, Parser } from "./parser.js";
|
|
4
5
|
import { ShellCompletion } from "./completion.js";
|
|
@@ -8,101 +9,55 @@ import { Program } from "./program.js";
|
|
|
8
9
|
//#region src/facade.d.ts
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Sub-configuration for a meta command's command form.
|
|
12
13
|
*
|
|
13
|
-
* @since 0.
|
|
14
|
-
*/
|
|
15
|
-
type CompletionName = "singular" | "plural" | "both";
|
|
16
|
-
/**
|
|
17
|
-
* Visibility policy for completion entries in help and usage output.
|
|
18
|
-
*
|
|
19
|
-
* @since 0.10.0
|
|
14
|
+
* @since 1.0.0
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
|
-
type CompletionConfigBase<THelp> = {
|
|
16
|
+
interface CommandSubConfig {
|
|
23
17
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* - `"both"`: Both `completion` subcommand and `--completion` option
|
|
28
|
-
* are available
|
|
29
|
-
*
|
|
30
|
-
* @default `"both"`
|
|
18
|
+
* Command names. The first element is the display name shown in help
|
|
19
|
+
* output; additional elements are hidden aliases that are accepted but
|
|
20
|
+
* not shown.
|
|
31
21
|
*/
|
|
32
|
-
readonly
|
|
22
|
+
readonly names?: readonly [string, ...string[]];
|
|
33
23
|
/**
|
|
34
|
-
* Group label for the
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @since 0.10.0
|
|
24
|
+
* Group label for the command in help output. When specified, the command
|
|
25
|
+
* appears under a titled section with this name instead of alongside
|
|
26
|
+
* user-defined commands.
|
|
39
27
|
*/
|
|
40
28
|
readonly group?: string;
|
|
41
29
|
/**
|
|
42
|
-
*
|
|
43
|
-
* `pwsh`, and `zsh`. You can provide additional custom shell completions
|
|
44
|
-
* or override the defaults.
|
|
30
|
+
* Granular visibility control.
|
|
45
31
|
*
|
|
46
|
-
*
|
|
32
|
+
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
33
|
+
* - `"usage"`: Hidden from usage lines only.
|
|
34
|
+
* - `"doc"`: Hidden from documentation only.
|
|
47
35
|
*/
|
|
48
|
-
readonly
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* @default Returns `void` when completion is shown.
|
|
57
|
-
*/
|
|
58
|
-
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
59
|
-
} | {
|
|
36
|
+
readonly hidden?: HiddenVisibility;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sub-configuration for a meta command's option form.
|
|
40
|
+
*
|
|
41
|
+
* @since 1.0.0
|
|
42
|
+
*/
|
|
43
|
+
interface OptionSubConfig {
|
|
60
44
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* - `"option"`: Only the `--completion` option is available
|
|
45
|
+
* Option names (all shown in help, e.g., `"-h"`, `"--help"`).
|
|
64
46
|
*/
|
|
65
|
-
readonly
|
|
66
|
-
/** @since 0.10.0 */
|
|
67
|
-
readonly group?: never;
|
|
68
|
-
/** @default `{ bash, fish, nu, pwsh, zsh }` */
|
|
69
|
-
readonly shells?: Record<string, ShellCompletion>;
|
|
70
|
-
/** @default Returns `void` when completion is shown. */
|
|
71
|
-
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
72
|
-
};
|
|
73
|
-
type CompletionConfigBoth<THelp> = CompletionConfigBase<THelp> & {
|
|
47
|
+
readonly names?: readonly [OptionName, ...OptionName[]];
|
|
74
48
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* - `"singular"`: Use `completion` / `--completion`
|
|
78
|
-
* - `"plural"`: Use `completions` / `--completions`
|
|
79
|
-
* - `"both"`: Use both singular and plural forms
|
|
80
|
-
*
|
|
81
|
-
* @default `"both"`
|
|
49
|
+
* Group label for the option in help output.
|
|
82
50
|
*/
|
|
83
|
-
readonly
|
|
51
|
+
readonly group?: string;
|
|
84
52
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* - `"both"`: Show both singular and plural entries
|
|
88
|
-
* - `"singular"`: Show only singular entries
|
|
89
|
-
* - `"plural"`: Show only plural entries
|
|
90
|
-
* - `"none"`: Hide completion entries from help and usage
|
|
53
|
+
* Granular visibility control.
|
|
91
54
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
55
|
+
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
56
|
+
* - `"usage"`: Hidden from usage lines only.
|
|
57
|
+
* - `"doc"`: Hidden from documentation only.
|
|
94
58
|
*/
|
|
95
|
-
readonly
|
|
96
|
-
}
|
|
97
|
-
type CompletionConfigSingular<THelp> = CompletionConfigBase<THelp> & {
|
|
98
|
-
readonly name: "singular";
|
|
99
|
-
readonly helpVisibility?: "singular" | "none";
|
|
100
|
-
};
|
|
101
|
-
type CompletionConfigPlural<THelp> = CompletionConfigBase<THelp> & {
|
|
102
|
-
readonly name: "plural";
|
|
103
|
-
readonly helpVisibility?: "plural" | "none";
|
|
104
|
-
};
|
|
105
|
-
type CompletionConfig<THelp> = CompletionConfigBoth<THelp> | CompletionConfigSingular<THelp> | CompletionConfigPlural<THelp>;
|
|
59
|
+
readonly hidden?: HiddenVisibility;
|
|
60
|
+
}
|
|
106
61
|
/**
|
|
107
62
|
* Configuration options for the {@link run} function.
|
|
108
63
|
*
|
|
@@ -163,125 +118,62 @@ interface RunOptions<THelp, TError> {
|
|
|
163
118
|
*/
|
|
164
119
|
readonly sectionOrder?: (a: DocSection, b: DocSection) => number;
|
|
165
120
|
/**
|
|
166
|
-
* Help configuration.
|
|
121
|
+
* Help configuration. When provided, enables help functionality.
|
|
122
|
+
* At least one of `command` or `option` must be specified.
|
|
123
|
+
*
|
|
124
|
+
* @since 1.0.0
|
|
167
125
|
*/
|
|
168
126
|
readonly help?: {
|
|
169
|
-
/**
|
|
170
|
-
* Determines how help is made available:
|
|
171
|
-
*
|
|
172
|
-
* - `"command"`: Only the `help` subcommand is available
|
|
173
|
-
* - `"both"`: Both `help` subcommand and `--help` option are available
|
|
174
|
-
*
|
|
175
|
-
* @default `"option"`
|
|
176
|
-
*/
|
|
177
|
-
readonly mode: "command" | "both";
|
|
178
|
-
/**
|
|
179
|
-
* Group label for the help command in help output. When specified,
|
|
180
|
-
* the help command appears under a titled section with this name
|
|
181
|
-
* instead of alongside user-defined commands.
|
|
182
|
-
*
|
|
183
|
-
* @since 0.10.0
|
|
184
|
-
*/
|
|
185
|
-
readonly group?: string;
|
|
186
|
-
/**
|
|
187
|
-
* Callback function invoked when help is requested. The function can
|
|
188
|
-
* optionally receive an exit code parameter.
|
|
189
|
-
*
|
|
190
|
-
* You usually want to pass `process.exit` on Node.js or Bun and
|
|
191
|
-
* `Deno.exit` on Deno to this option.
|
|
192
|
-
*
|
|
193
|
-
* @default Returns `void` when help is shown.
|
|
194
|
-
*/
|
|
127
|
+
/** Callback invoked when help is requested. */
|
|
195
128
|
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
129
|
+
} & ({
|
|
130
|
+
readonly command: true | CommandSubConfig;
|
|
131
|
+
readonly option?: true | OptionSubConfig;
|
|
196
132
|
} | {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* - `"option"`: Only the `--help` option is available
|
|
201
|
-
*
|
|
202
|
-
* @default `"option"`
|
|
203
|
-
*/
|
|
204
|
-
readonly mode?: "option";
|
|
205
|
-
/** @since 0.10.0 */
|
|
206
|
-
readonly group?: never;
|
|
207
|
-
/**
|
|
208
|
-
* Callback function invoked when help is requested. The function can
|
|
209
|
-
* optionally receive an exit code parameter.
|
|
210
|
-
*
|
|
211
|
-
* You usually want to pass `process.exit` on Node.js or Bun and
|
|
212
|
-
* `Deno.exit` on Deno to this option.
|
|
213
|
-
*
|
|
214
|
-
* @default Returns `void` when help is shown.
|
|
215
|
-
*/
|
|
216
|
-
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
217
|
-
};
|
|
133
|
+
readonly option: true | OptionSubConfig;
|
|
134
|
+
readonly command?: true | CommandSubConfig;
|
|
135
|
+
});
|
|
218
136
|
/**
|
|
219
|
-
* Version configuration.
|
|
137
|
+
* Version configuration. When provided, enables version functionality.
|
|
138
|
+
* At least one of `command` or `option` must be specified.
|
|
139
|
+
*
|
|
140
|
+
* @since 1.0.0
|
|
220
141
|
*/
|
|
221
142
|
readonly version?: {
|
|
222
|
-
/**
|
|
223
|
-
* Determines how version is made available:
|
|
224
|
-
*
|
|
225
|
-
* - `"command"`: Only the `version` subcommand is available
|
|
226
|
-
* - `"both"`: Both `version` subcommand and `--version` option are
|
|
227
|
-
* available
|
|
228
|
-
*
|
|
229
|
-
* @default `"option"`
|
|
230
|
-
*/
|
|
231
|
-
readonly mode: "command" | "both";
|
|
232
|
-
/**
|
|
233
|
-
* The version string to display when version is requested.
|
|
234
|
-
*/
|
|
143
|
+
/** The version string to display when version is requested. */
|
|
235
144
|
readonly value: string;
|
|
236
|
-
/**
|
|
237
|
-
* Group label for the version command in help output. When specified,
|
|
238
|
-
* the version command appears under a titled section with this name
|
|
239
|
-
* instead of alongside user-defined commands.
|
|
240
|
-
*
|
|
241
|
-
* @since 0.10.0
|
|
242
|
-
*/
|
|
243
|
-
readonly group?: string;
|
|
244
|
-
/**
|
|
245
|
-
* Callback function invoked when version is requested. The function can
|
|
246
|
-
* optionally receive an exit code parameter.
|
|
247
|
-
*
|
|
248
|
-
* You usually want to pass `process.exit` on Node.js or Bun and
|
|
249
|
-
* `Deno.exit` on Deno to this option.
|
|
250
|
-
*
|
|
251
|
-
* @default Returns `void` when version is shown.
|
|
252
|
-
*/
|
|
145
|
+
/** Callback invoked when version is requested. */
|
|
253
146
|
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
147
|
+
} & ({
|
|
148
|
+
readonly command: true | CommandSubConfig;
|
|
149
|
+
readonly option?: true | OptionSubConfig;
|
|
254
150
|
} | {
|
|
151
|
+
readonly option: true | OptionSubConfig;
|
|
152
|
+
readonly command?: true | CommandSubConfig;
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* Completion configuration. When provided, enables shell completion.
|
|
156
|
+
* At least one of `command` or `option` must be specified.
|
|
157
|
+
*
|
|
158
|
+
* @since 1.0.0
|
|
159
|
+
*/
|
|
160
|
+
readonly completion?: {
|
|
255
161
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* - `"option"`: Only the `--version` option is available
|
|
259
|
-
*
|
|
260
|
-
* @default `"option"`
|
|
261
|
-
*/
|
|
262
|
-
readonly mode?: "option";
|
|
263
|
-
/**
|
|
264
|
-
* The version string to display when version is requested.
|
|
265
|
-
*/
|
|
266
|
-
readonly value: string;
|
|
267
|
-
/** @since 0.10.0 */
|
|
268
|
-
readonly group?: never;
|
|
269
|
-
/**
|
|
270
|
-
* Callback function invoked when version is requested. The function can
|
|
271
|
-
* optionally receive an exit code parameter.
|
|
162
|
+
* Available shell completions. By default, includes `bash`, `fish`,
|
|
163
|
+
* `nu`, `pwsh`, and `zsh`.
|
|
272
164
|
*
|
|
273
|
-
*
|
|
274
|
-
* `Deno.exit` on Deno to this option.
|
|
275
|
-
*
|
|
276
|
-
* @default Returns `void` when version is shown.
|
|
165
|
+
* @default `{ bash, fish, nu, pwsh, zsh }`
|
|
277
166
|
*/
|
|
167
|
+
readonly shells?: Record<string, ShellCompletion>;
|
|
168
|
+
/** Callback invoked when completion is requested. */
|
|
278
169
|
readonly onShow?: (() => THelp) | ((exitCode: number) => THelp);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
170
|
+
} & ({
|
|
171
|
+
readonly command: true | CommandSubConfig;
|
|
172
|
+
readonly option?: true | OptionSubConfig;
|
|
173
|
+
} | {
|
|
174
|
+
readonly option: true | OptionSubConfig;
|
|
175
|
+
readonly command?: true | CommandSubConfig;
|
|
176
|
+
});
|
|
285
177
|
/**
|
|
286
178
|
* What to display above error messages:
|
|
287
179
|
* - `"usage"`: Show usage information
|
|
@@ -559,4 +451,4 @@ declare function runWithSync<TParser extends Parser<"sync", unknown, unknown>, T
|
|
|
559
451
|
*/
|
|
560
452
|
declare function runWithAsync<TParser extends Parser<Mode, unknown, unknown>, TContexts extends readonly SourceContext<unknown>[], THelp = void, TError = never>(parser: TParser, programName: string, contexts: TContexts, options: RunWithOptions<THelp, TError> & ExtractRequiredOptions<TContexts, InferValue<TParser>>): Promise<InferValue<TParser>>;
|
|
561
453
|
//#endregion
|
|
562
|
-
export {
|
|
454
|
+
export { CommandSubConfig, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|