@optique/run 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/run.cjs CHANGED
@@ -55,79 +55,71 @@ function runAsync(parserOrProgram, options = {}) {
55
55
  * @internal
56
56
  */
57
57
  function buildCoreOptions(options, programMetadata) {
58
- const { programName = node_path.default.basename(node_process.default.argv[1] || "cli"), args = node_process.default.argv.slice(2), colors = node_process.default.stdout.isTTY, maxWidth = node_process.default.stdout.columns, showDefault, showChoices, sectionOrder, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
59
- const helpConfig = help ? typeof help === "string" ? {
60
- mode: help,
61
- onShow: () => node_process.default.exit(0)
62
- } : {
63
- mode: help.mode,
64
- group: help.group,
65
- onShow: () => node_process.default.exit(0)
66
- } : void 0;
58
+ const { programName = node_path.default.basename(node_process.default.argv[1] || "cli"), args = node_process.default.argv.slice(2), stdout = (line) => {
59
+ node_process.default.stdout.write(`${line}\n`);
60
+ }, stderr = (line) => {
61
+ node_process.default.stderr.write(`${line}\n`);
62
+ }, onExit = (exitCode) => node_process.default.exit(exitCode), colors = node_process.default.stdout.isTTY, maxWidth = node_process.default.stdout.columns, showDefault, showChoices, sectionOrder, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
63
+ const onShow = () => onExit(0);
64
+ const helpConfig = (() => {
65
+ if (!help) return void 0;
66
+ if (typeof help === "string") switch (help) {
67
+ case "command": return {
68
+ command: true,
69
+ onShow
70
+ };
71
+ case "option": return {
72
+ option: true,
73
+ onShow
74
+ };
75
+ case "both": return {
76
+ command: true,
77
+ option: true,
78
+ onShow
79
+ };
80
+ }
81
+ return {
82
+ ...help,
83
+ onShow
84
+ };
85
+ })();
67
86
  const versionConfig = (() => {
68
87
  if (!version) return void 0;
69
88
  if (typeof version === "string") return {
70
- mode: "option",
71
89
  value: version,
72
- onShow: () => node_process.default.exit(0)
73
- };
74
- const mode = version.mode ?? "option";
75
- if (mode === "command" || mode === "both") return {
76
- mode,
77
- value: version.value,
78
- group: version.group,
79
- onShow: () => node_process.default.exit(0)
90
+ option: true,
91
+ onShow
80
92
  };
81
93
  return {
82
- mode,
83
- value: version.value,
84
- onShow: () => node_process.default.exit(0)
94
+ ...version,
95
+ onShow
85
96
  };
86
97
  })();
87
98
  const completionConfig = (() => {
88
99
  if (!completion) return void 0;
89
- const onShow = () => node_process.default.exit(0);
90
- if (typeof completion === "string") return {
91
- mode: completion,
92
- name: "both",
93
- helpVisibility: "both",
94
- onShow
95
- };
96
- const mode = completion.mode ?? "both";
97
- const shells = completion.shells;
98
- const cGroup = completion.group;
99
- if (completion.name === "singular") return {
100
- mode,
101
- shells,
102
- ...cGroup != null && { group: cGroup },
103
- name: "singular",
104
- helpVisibility: completion.helpVisibility ?? "singular",
105
- onShow
106
- };
107
- if (completion.name === "plural") return {
108
- mode,
109
- shells,
110
- ...cGroup != null && { group: cGroup },
111
- name: "plural",
112
- helpVisibility: completion.helpVisibility ?? "plural",
113
- onShow
114
- };
100
+ if (typeof completion === "string") switch (completion) {
101
+ case "command": return {
102
+ command: true,
103
+ onShow
104
+ };
105
+ case "option": return {
106
+ option: true,
107
+ onShow
108
+ };
109
+ case "both": return {
110
+ command: true,
111
+ option: true,
112
+ onShow
113
+ };
114
+ }
115
115
  return {
116
- mode,
117
- shells,
118
- ...cGroup != null && { group: cGroup },
119
- name: "both",
120
- helpVisibility: completion.helpVisibility ?? "both",
116
+ ...completion,
121
117
  onShow
122
118
  };
123
119
  })();
124
120
  const coreOptions = {
125
- stderr(line) {
126
- node_process.default.stderr.write(`${line}\n`);
127
- },
128
- stdout(line) {
129
- node_process.default.stdout.write(`${line}\n`);
130
- },
121
+ stderr,
122
+ stdout,
131
123
  colors,
132
124
  maxWidth,
133
125
  showDefault,
@@ -144,7 +136,7 @@ function buildCoreOptions(options, programMetadata) {
144
136
  bugs,
145
137
  footer,
146
138
  onError() {
147
- return node_process.default.exit(errorExitCode);
139
+ return onExit(errorExitCode);
148
140
  }
149
141
  };
150
142
  return {
@@ -160,6 +152,9 @@ function buildCoreOptions(options, programMetadata) {
160
152
  const knownRunOptionsKeys = new Set([
161
153
  "programName",
162
154
  "args",
155
+ "stdout",
156
+ "stderr",
157
+ "onExit",
163
158
  "colors",
164
159
  "maxWidth",
165
160
  "showDefault",
package/dist/run.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ShellCompletion } from "@optique/core/completion";
2
2
  import { SourceContext } from "@optique/core/context";
3
- import { ExtractRequiredOptions } from "@optique/core/facade";
3
+ import { CommandSubConfig, ExtractRequiredOptions, OptionSubConfig } from "@optique/core/facade";
4
4
  import { InferMode, InferValue, Mode, ModeValue, Parser } from "@optique/core/parser";
5
5
  import { Program } from "@optique/core/program";
6
6
  import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "@optique/core/doc";
@@ -24,6 +24,26 @@ interface RunOptions {
24
24
  * @default `process.argv.slice(2)` (arguments after the script name)
25
25
  */
26
26
  readonly args?: readonly string[];
27
+ /**
28
+ * Function used to output help and usage messages. Assumes it prints the
29
+ * ending newline.
30
+ *
31
+ * @default Writes to `process.stdout` with a trailing newline
32
+ */
33
+ readonly stdout?: (text: string) => void;
34
+ /**
35
+ * Function used to output error messages. Assumes it prints the ending
36
+ * newline.
37
+ *
38
+ * @default Writes to `process.stderr` with a trailing newline
39
+ */
40
+ readonly stderr?: (text: string) => void;
41
+ /**
42
+ * Function used to exit the process on help/version display or parse error.
43
+ *
44
+ * @default `process.exit`
45
+ */
46
+ readonly onExit?: (exitCode: number) => never;
27
47
  /**
28
48
  * Whether to enable colored output in help and error messages.
29
49
  *
@@ -84,63 +104,66 @@ interface RunOptions {
84
104
  * - `"command"`: Only the `help` subcommand is available
85
105
  * - `"option"`: Only the `--help` option is available
86
106
  * - `"both"`: Both `help` subcommand and `--help` option are available
87
- * - `object`: Advanced configuration with mode and group
88
- * - `mode`: "command" | "both"
89
- * - `group`: Group label for help command in help output (optional)
107
+ * - `object`: Advanced configuration with `command` and/or `option`
108
+ * sub-configs. At least one of `command` or `option` must be specified.
90
109
  *
91
110
  * When not provided, help functionality is disabled.
111
+ *
112
+ * @since 1.0.0
92
113
  */
93
- readonly help?: "command" | "option" | "both" | {
94
- readonly mode: "command" | "both";
95
- /**
96
- * Group label for the help command in help output.
97
- * @since 0.10.0
98
- */
99
- readonly group?: string;
100
- };
114
+ readonly help?: "command" | "option" | "both" | (({
115
+ readonly command: true | CommandSubConfig;
116
+ readonly option?: true | OptionSubConfig;
117
+ } | {
118
+ readonly option: true | OptionSubConfig;
119
+ readonly command?: true | CommandSubConfig;
120
+ }));
101
121
  /**
102
122
  * Version configuration. Determines how version is made available:
103
123
  *
104
124
  * - `string`: Version value with default `"option"` mode (--version only)
105
- * - `object`: Advanced configuration with version value and mode
106
- * - `value`: The version string to display
107
- * - `mode`: "command" | "option" | "both" (default: "option")
108
- * - `group`: Group label for version command in help output (only
109
- * when mode is "command" or "both")
125
+ * - `object`: Advanced configuration with version value and `command`
126
+ * and/or `option` sub-configs. At least one of `command` or `option`
127
+ * must be specified.
110
128
  *
111
129
  * When not provided, version functionality is disabled.
130
+ *
131
+ * @since 1.0.0
112
132
  */
113
- readonly version?: string | {
133
+ readonly version?: string | ({
114
134
  readonly value: string;
115
- readonly mode: "command" | "both";
116
- /**
117
- * Group label for the version command in help output.
118
- * @since 0.10.0
119
- */
120
- readonly group?: string;
135
+ } & ({
136
+ readonly command: true | CommandSubConfig;
137
+ readonly option?: true | OptionSubConfig;
121
138
  } | {
122
- readonly value: string;
123
- readonly mode?: "option";
124
- readonly group?: never;
125
- };
139
+ readonly option: true | OptionSubConfig;
140
+ readonly command?: true | CommandSubConfig;
141
+ }));
126
142
  /**
127
- * Completion configuration. Determines how shell completion is made available:
143
+ * Completion configuration. Determines how shell completion is made
144
+ * available:
128
145
  *
129
146
  * - `"command"`: Only the `completion` subcommand is available
130
147
  * - `"option"`: Only the `--completion` option is available
131
- * - `"both"`: Both `completion` subcommand and `--completion` option are available
132
- * - `object`: Advanced configuration with mode and custom shells
133
- * - `mode`: "command" | "option" | "both" (default: "both")
134
- * - `name`: "singular" | "plural" | "both" (default: "both")
135
- * - `helpVisibility`: "singular" | "plural" | "both" | "none"
136
- * (default: matches `name`)
137
- * - `shells`: Custom shell completions (optional)
148
+ * - `"both"`: Both `completion` subcommand and `--completion` option
149
+ * are available
150
+ * - `object`: Advanced configuration with `command` and/or `option`
151
+ * sub-configs and optional custom shells. At least one of `command`
152
+ * or `option` must be specified.
138
153
  *
139
154
  * When not provided, completion functionality is disabled.
140
155
  *
141
- * @since 0.6.0
156
+ * @since 1.0.0
142
157
  */
143
- readonly completion?: "command" | "option" | "both" | CompletionOptions;
158
+ readonly completion?: "command" | "option" | "both" | ({
159
+ readonly shells?: Record<string, ShellCompletion>;
160
+ } & ({
161
+ readonly command: true | CommandSubConfig;
162
+ readonly option?: true | OptionSubConfig;
163
+ } | {
164
+ readonly option: true | OptionSubConfig;
165
+ readonly command?: true | CommandSubConfig;
166
+ }));
144
167
  /**
145
168
  * What to display above error messages:
146
169
  *
@@ -203,48 +226,6 @@ interface RunOptions {
203
226
  */
204
227
  readonly contexts?: readonly SourceContext<unknown>[];
205
228
  }
206
- type CompletionHelpVisibility = "singular" | "plural" | "both" | "none";
207
- type CompletionOptionsBase = {
208
- readonly mode?: "command" | "both";
209
- /**
210
- * Group label for the completion command in help output.
211
- * @since 0.10.0
212
- */
213
- readonly group?: string;
214
- readonly shells?: Record<string, ShellCompletion>;
215
- } | {
216
- readonly mode: "option";
217
- readonly group?: never;
218
- readonly shells?: Record<string, ShellCompletion>;
219
- };
220
- type CompletionOptionsBoth = CompletionOptionsBase & {
221
- readonly name?: "both";
222
- /**
223
- * Controls which completion aliases are shown in help and usage output.
224
- *
225
- * @since 0.10.0
226
- */
227
- readonly helpVisibility?: CompletionHelpVisibility;
228
- };
229
- type CompletionOptionsSingular = CompletionOptionsBase & {
230
- readonly name: "singular";
231
- /**
232
- * Controls which completion aliases are shown in help and usage output.
233
- *
234
- * @since 0.10.0
235
- */
236
- readonly helpVisibility?: "singular" | "none";
237
- };
238
- type CompletionOptionsPlural = CompletionOptionsBase & {
239
- readonly name: "plural";
240
- /**
241
- * Controls which completion aliases are shown in help and usage output.
242
- *
243
- * @since 0.10.0
244
- */
245
- readonly helpVisibility?: "plural" | "none";
246
- };
247
- type CompletionOptions = CompletionOptionsBoth | CompletionOptionsSingular | CompletionOptionsPlural;
248
229
  /**
249
230
  * Runs a command-line parser with automatic process integration.
250
231
  *
package/dist/run.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ExtractRequiredOptions } from "@optique/core/facade";
1
+ import { CommandSubConfig, ExtractRequiredOptions, OptionSubConfig } from "@optique/core/facade";
2
2
  import { Message } from "@optique/core/message";
3
3
  import { ShellCompletion } from "@optique/core/completion";
4
4
  import { SourceContext } from "@optique/core/context";
@@ -24,6 +24,26 @@ interface RunOptions {
24
24
  * @default `process.argv.slice(2)` (arguments after the script name)
25
25
  */
26
26
  readonly args?: readonly string[];
27
+ /**
28
+ * Function used to output help and usage messages. Assumes it prints the
29
+ * ending newline.
30
+ *
31
+ * @default Writes to `process.stdout` with a trailing newline
32
+ */
33
+ readonly stdout?: (text: string) => void;
34
+ /**
35
+ * Function used to output error messages. Assumes it prints the ending
36
+ * newline.
37
+ *
38
+ * @default Writes to `process.stderr` with a trailing newline
39
+ */
40
+ readonly stderr?: (text: string) => void;
41
+ /**
42
+ * Function used to exit the process on help/version display or parse error.
43
+ *
44
+ * @default `process.exit`
45
+ */
46
+ readonly onExit?: (exitCode: number) => never;
27
47
  /**
28
48
  * Whether to enable colored output in help and error messages.
29
49
  *
@@ -84,63 +104,66 @@ interface RunOptions {
84
104
  * - `"command"`: Only the `help` subcommand is available
85
105
  * - `"option"`: Only the `--help` option is available
86
106
  * - `"both"`: Both `help` subcommand and `--help` option are available
87
- * - `object`: Advanced configuration with mode and group
88
- * - `mode`: "command" | "both"
89
- * - `group`: Group label for help command in help output (optional)
107
+ * - `object`: Advanced configuration with `command` and/or `option`
108
+ * sub-configs. At least one of `command` or `option` must be specified.
90
109
  *
91
110
  * When not provided, help functionality is disabled.
111
+ *
112
+ * @since 1.0.0
92
113
  */
93
- readonly help?: "command" | "option" | "both" | {
94
- readonly mode: "command" | "both";
95
- /**
96
- * Group label for the help command in help output.
97
- * @since 0.10.0
98
- */
99
- readonly group?: string;
100
- };
114
+ readonly help?: "command" | "option" | "both" | (({
115
+ readonly command: true | CommandSubConfig;
116
+ readonly option?: true | OptionSubConfig;
117
+ } | {
118
+ readonly option: true | OptionSubConfig;
119
+ readonly command?: true | CommandSubConfig;
120
+ }));
101
121
  /**
102
122
  * Version configuration. Determines how version is made available:
103
123
  *
104
124
  * - `string`: Version value with default `"option"` mode (--version only)
105
- * - `object`: Advanced configuration with version value and mode
106
- * - `value`: The version string to display
107
- * - `mode`: "command" | "option" | "both" (default: "option")
108
- * - `group`: Group label for version command in help output (only
109
- * when mode is "command" or "both")
125
+ * - `object`: Advanced configuration with version value and `command`
126
+ * and/or `option` sub-configs. At least one of `command` or `option`
127
+ * must be specified.
110
128
  *
111
129
  * When not provided, version functionality is disabled.
130
+ *
131
+ * @since 1.0.0
112
132
  */
113
- readonly version?: string | {
133
+ readonly version?: string | ({
114
134
  readonly value: string;
115
- readonly mode: "command" | "both";
116
- /**
117
- * Group label for the version command in help output.
118
- * @since 0.10.0
119
- */
120
- readonly group?: string;
135
+ } & ({
136
+ readonly command: true | CommandSubConfig;
137
+ readonly option?: true | OptionSubConfig;
121
138
  } | {
122
- readonly value: string;
123
- readonly mode?: "option";
124
- readonly group?: never;
125
- };
139
+ readonly option: true | OptionSubConfig;
140
+ readonly command?: true | CommandSubConfig;
141
+ }));
126
142
  /**
127
- * Completion configuration. Determines how shell completion is made available:
143
+ * Completion configuration. Determines how shell completion is made
144
+ * available:
128
145
  *
129
146
  * - `"command"`: Only the `completion` subcommand is available
130
147
  * - `"option"`: Only the `--completion` option is available
131
- * - `"both"`: Both `completion` subcommand and `--completion` option are available
132
- * - `object`: Advanced configuration with mode and custom shells
133
- * - `mode`: "command" | "option" | "both" (default: "both")
134
- * - `name`: "singular" | "plural" | "both" (default: "both")
135
- * - `helpVisibility`: "singular" | "plural" | "both" | "none"
136
- * (default: matches `name`)
137
- * - `shells`: Custom shell completions (optional)
148
+ * - `"both"`: Both `completion` subcommand and `--completion` option
149
+ * are available
150
+ * - `object`: Advanced configuration with `command` and/or `option`
151
+ * sub-configs and optional custom shells. At least one of `command`
152
+ * or `option` must be specified.
138
153
  *
139
154
  * When not provided, completion functionality is disabled.
140
155
  *
141
- * @since 0.6.0
156
+ * @since 1.0.0
142
157
  */
143
- readonly completion?: "command" | "option" | "both" | CompletionOptions;
158
+ readonly completion?: "command" | "option" | "both" | ({
159
+ readonly shells?: Record<string, ShellCompletion>;
160
+ } & ({
161
+ readonly command: true | CommandSubConfig;
162
+ readonly option?: true | OptionSubConfig;
163
+ } | {
164
+ readonly option: true | OptionSubConfig;
165
+ readonly command?: true | CommandSubConfig;
166
+ }));
144
167
  /**
145
168
  * What to display above error messages:
146
169
  *
@@ -203,48 +226,6 @@ interface RunOptions {
203
226
  */
204
227
  readonly contexts?: readonly SourceContext<unknown>[];
205
228
  }
206
- type CompletionHelpVisibility = "singular" | "plural" | "both" | "none";
207
- type CompletionOptionsBase = {
208
- readonly mode?: "command" | "both";
209
- /**
210
- * Group label for the completion command in help output.
211
- * @since 0.10.0
212
- */
213
- readonly group?: string;
214
- readonly shells?: Record<string, ShellCompletion>;
215
- } | {
216
- readonly mode: "option";
217
- readonly group?: never;
218
- readonly shells?: Record<string, ShellCompletion>;
219
- };
220
- type CompletionOptionsBoth = CompletionOptionsBase & {
221
- readonly name?: "both";
222
- /**
223
- * Controls which completion aliases are shown in help and usage output.
224
- *
225
- * @since 0.10.0
226
- */
227
- readonly helpVisibility?: CompletionHelpVisibility;
228
- };
229
- type CompletionOptionsSingular = CompletionOptionsBase & {
230
- readonly name: "singular";
231
- /**
232
- * Controls which completion aliases are shown in help and usage output.
233
- *
234
- * @since 0.10.0
235
- */
236
- readonly helpVisibility?: "singular" | "none";
237
- };
238
- type CompletionOptionsPlural = CompletionOptionsBase & {
239
- readonly name: "plural";
240
- /**
241
- * Controls which completion aliases are shown in help and usage output.
242
- *
243
- * @since 0.10.0
244
- */
245
- readonly helpVisibility?: "plural" | "none";
246
- };
247
- type CompletionOptions = CompletionOptionsBoth | CompletionOptionsSingular | CompletionOptionsPlural;
248
229
  /**
249
230
  * Runs a command-line parser with automatic process integration.
250
231
  *
package/dist/run.js CHANGED
@@ -54,79 +54,71 @@ function runAsync(parserOrProgram, options = {}) {
54
54
  * @internal
55
55
  */
56
56
  function buildCoreOptions(options, programMetadata) {
57
- const { programName = path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, showDefault, showChoices, sectionOrder, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
58
- const helpConfig = help ? typeof help === "string" ? {
59
- mode: help,
60
- onShow: () => process.exit(0)
61
- } : {
62
- mode: help.mode,
63
- group: help.group,
64
- onShow: () => process.exit(0)
65
- } : void 0;
57
+ const { programName = path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), stdout = (line) => {
58
+ process.stdout.write(`${line}\n`);
59
+ }, stderr = (line) => {
60
+ process.stderr.write(`${line}\n`);
61
+ }, onExit = (exitCode) => process.exit(exitCode), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, showDefault, showChoices, sectionOrder, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
62
+ const onShow = () => onExit(0);
63
+ const helpConfig = (() => {
64
+ if (!help) return void 0;
65
+ if (typeof help === "string") switch (help) {
66
+ case "command": return {
67
+ command: true,
68
+ onShow
69
+ };
70
+ case "option": return {
71
+ option: true,
72
+ onShow
73
+ };
74
+ case "both": return {
75
+ command: true,
76
+ option: true,
77
+ onShow
78
+ };
79
+ }
80
+ return {
81
+ ...help,
82
+ onShow
83
+ };
84
+ })();
66
85
  const versionConfig = (() => {
67
86
  if (!version) return void 0;
68
87
  if (typeof version === "string") return {
69
- mode: "option",
70
88
  value: version,
71
- onShow: () => process.exit(0)
72
- };
73
- const mode = version.mode ?? "option";
74
- if (mode === "command" || mode === "both") return {
75
- mode,
76
- value: version.value,
77
- group: version.group,
78
- onShow: () => process.exit(0)
89
+ option: true,
90
+ onShow
79
91
  };
80
92
  return {
81
- mode,
82
- value: version.value,
83
- onShow: () => process.exit(0)
93
+ ...version,
94
+ onShow
84
95
  };
85
96
  })();
86
97
  const completionConfig = (() => {
87
98
  if (!completion) return void 0;
88
- const onShow = () => process.exit(0);
89
- if (typeof completion === "string") return {
90
- mode: completion,
91
- name: "both",
92
- helpVisibility: "both",
93
- onShow
94
- };
95
- const mode = completion.mode ?? "both";
96
- const shells = completion.shells;
97
- const cGroup = completion.group;
98
- if (completion.name === "singular") return {
99
- mode,
100
- shells,
101
- ...cGroup != null && { group: cGroup },
102
- name: "singular",
103
- helpVisibility: completion.helpVisibility ?? "singular",
104
- onShow
105
- };
106
- if (completion.name === "plural") return {
107
- mode,
108
- shells,
109
- ...cGroup != null && { group: cGroup },
110
- name: "plural",
111
- helpVisibility: completion.helpVisibility ?? "plural",
112
- onShow
113
- };
99
+ if (typeof completion === "string") switch (completion) {
100
+ case "command": return {
101
+ command: true,
102
+ onShow
103
+ };
104
+ case "option": return {
105
+ option: true,
106
+ onShow
107
+ };
108
+ case "both": return {
109
+ command: true,
110
+ option: true,
111
+ onShow
112
+ };
113
+ }
114
114
  return {
115
- mode,
116
- shells,
117
- ...cGroup != null && { group: cGroup },
118
- name: "both",
119
- helpVisibility: completion.helpVisibility ?? "both",
115
+ ...completion,
120
116
  onShow
121
117
  };
122
118
  })();
123
119
  const coreOptions = {
124
- stderr(line) {
125
- process.stderr.write(`${line}\n`);
126
- },
127
- stdout(line) {
128
- process.stdout.write(`${line}\n`);
129
- },
120
+ stderr,
121
+ stdout,
130
122
  colors,
131
123
  maxWidth,
132
124
  showDefault,
@@ -143,7 +135,7 @@ function buildCoreOptions(options, programMetadata) {
143
135
  bugs,
144
136
  footer,
145
137
  onError() {
146
- return process.exit(errorExitCode);
138
+ return onExit(errorExitCode);
147
139
  }
148
140
  };
149
141
  return {
@@ -159,6 +151,9 @@ function buildCoreOptions(options, programMetadata) {
159
151
  const knownRunOptionsKeys = new Set([
160
152
  "programName",
161
153
  "args",
154
+ "stdout",
155
+ "stderr",
156
+ "onExit",
162
157
  "colors",
163
158
  "maxWidth",
164
159
  "showDefault",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/run",
3
- "version": "1.0.0-dev.431+01c1abaf",
3
+ "version": "1.0.0-dev.434+bf14eac1",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "sideEffects": false,
72
72
  "dependencies": {
73
- "@optique/core": "1.0.0-dev.431+01c1abaf"
73
+ "@optique/core": "1.0.0-dev.434+bf14eac1"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.19.9",