@optique/run 0.10.0-dev.374 → 0.10.0-dev.375

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
@@ -33,46 +33,69 @@ function runImpl(parserOrProgram, options = {}) {
33
33
  };
34
34
  } else parser = parserOrProgram;
35
35
  const { programName = programNameFromProgram ?? 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, 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;
36
- const helpConfig = help ? {
36
+ const helpConfig = help ? typeof help === "string" ? {
37
37
  mode: help,
38
38
  onShow: () => node_process.default.exit(0)
39
- } : void 0;
40
- const versionConfig = version ? {
41
- mode: typeof version === "string" ? "option" : version.mode ?? "option",
42
- value: typeof version === "string" ? version : version.value,
39
+ } : {
40
+ mode: help.mode,
41
+ group: help.group,
43
42
  onShow: () => node_process.default.exit(0)
44
43
  } : void 0;
44
+ const versionConfig = (() => {
45
+ if (!version) return void 0;
46
+ if (typeof version === "string") return {
47
+ mode: "option",
48
+ value: version,
49
+ onShow: () => node_process.default.exit(0)
50
+ };
51
+ const mode = version.mode ?? "option";
52
+ if (mode === "command" || mode === "both") return {
53
+ mode,
54
+ value: version.value,
55
+ group: version.group,
56
+ onShow: () => node_process.default.exit(0)
57
+ };
58
+ return {
59
+ mode,
60
+ value: version.value,
61
+ onShow: () => node_process.default.exit(0)
62
+ };
63
+ })();
45
64
  const completionConfig = (() => {
46
65
  if (!completion) return void 0;
66
+ const onShow = () => node_process.default.exit(0);
47
67
  if (typeof completion === "string") return {
48
68
  mode: completion,
49
- shells: void 0,
50
69
  name: "both",
51
70
  helpVisibility: "both",
52
- onShow: () => node_process.default.exit(0)
71
+ onShow
53
72
  };
54
73
  const mode = completion.mode ?? "both";
55
74
  const shells = completion.shells;
75
+ const cGroup = completion.group;
56
76
  if (completion.name === "singular") return {
57
77
  mode,
58
78
  shells,
79
+ ...cGroup != null && { group: cGroup },
59
80
  name: "singular",
60
81
  helpVisibility: completion.helpVisibility ?? "singular",
61
- onShow: () => node_process.default.exit(0)
82
+ onShow
62
83
  };
63
84
  if (completion.name === "plural") return {
64
85
  mode,
65
86
  shells,
87
+ ...cGroup != null && { group: cGroup },
66
88
  name: "plural",
67
89
  helpVisibility: completion.helpVisibility ?? "plural",
68
- onShow: () => node_process.default.exit(0)
90
+ onShow
69
91
  };
70
92
  return {
71
93
  mode,
72
94
  shells,
95
+ ...cGroup != null && { group: cGroup },
73
96
  name: "both",
74
97
  helpVisibility: completion.helpVisibility ?? "both",
75
- onShow: () => node_process.default.exit(0)
98
+ onShow
76
99
  };
77
100
  })();
78
101
  return (0, __optique_core_facade.runParser)(parser, programName, args, {
package/dist/run.d.cts CHANGED
@@ -68,10 +68,20 @@ interface RunOptions {
68
68
  * - `"command"`: Only the `help` subcommand is available
69
69
  * - `"option"`: Only the `--help` option is available
70
70
  * - `"both"`: Both `help` subcommand and `--help` option are available
71
+ * - `object`: Advanced configuration with mode and group
72
+ * - `mode`: "command" | "both"
73
+ * - `group`: Group label for help command in help output (optional)
71
74
  *
72
75
  * When not provided, help functionality is disabled.
73
76
  */
74
- readonly help?: "command" | "option" | "both";
77
+ readonly help?: "command" | "option" | "both" | {
78
+ readonly mode: "command" | "both";
79
+ /**
80
+ * Group label for the help command in help output.
81
+ * @since 0.10.0
82
+ */
83
+ readonly group?: string;
84
+ };
75
85
  /**
76
86
  * Version configuration. Determines how version is made available:
77
87
  *
@@ -79,12 +89,23 @@ interface RunOptions {
79
89
  * - `object`: Advanced configuration with version value and mode
80
90
  * - `value`: The version string to display
81
91
  * - `mode`: "command" | "option" | "both" (default: "option")
92
+ * - `group`: Group label for version command in help output (only
93
+ * when mode is "command" or "both")
82
94
  *
83
95
  * When not provided, version functionality is disabled.
84
96
  */
85
97
  readonly version?: string | {
86
98
  readonly value: string;
87
- readonly mode?: "command" | "option" | "both";
99
+ readonly mode: "command" | "both";
100
+ /**
101
+ * Group label for the version command in help output.
102
+ * @since 0.10.0
103
+ */
104
+ readonly group?: string;
105
+ } | {
106
+ readonly value: string;
107
+ readonly mode?: "option";
108
+ readonly group?: never;
88
109
  };
89
110
  /**
90
111
  * Completion configuration. Determines how shell completion is made available:
@@ -159,7 +180,16 @@ interface RunOptions {
159
180
  }
160
181
  type CompletionHelpVisibility = "singular" | "plural" | "both" | "none";
161
182
  type CompletionOptionsBase = {
162
- readonly mode?: "command" | "option" | "both";
183
+ readonly mode?: "command" | "both";
184
+ /**
185
+ * Group label for the completion command in help output.
186
+ * @since 0.10.0
187
+ */
188
+ readonly group?: string;
189
+ readonly shells?: Record<string, ShellCompletion>;
190
+ } | {
191
+ readonly mode: "option";
192
+ readonly group?: never;
163
193
  readonly shells?: Record<string, ShellCompletion>;
164
194
  };
165
195
  type CompletionOptionsBoth = CompletionOptionsBase & {
package/dist/run.d.ts CHANGED
@@ -68,10 +68,20 @@ interface RunOptions {
68
68
  * - `"command"`: Only the `help` subcommand is available
69
69
  * - `"option"`: Only the `--help` option is available
70
70
  * - `"both"`: Both `help` subcommand and `--help` option are available
71
+ * - `object`: Advanced configuration with mode and group
72
+ * - `mode`: "command" | "both"
73
+ * - `group`: Group label for help command in help output (optional)
71
74
  *
72
75
  * When not provided, help functionality is disabled.
73
76
  */
74
- readonly help?: "command" | "option" | "both";
77
+ readonly help?: "command" | "option" | "both" | {
78
+ readonly mode: "command" | "both";
79
+ /**
80
+ * Group label for the help command in help output.
81
+ * @since 0.10.0
82
+ */
83
+ readonly group?: string;
84
+ };
75
85
  /**
76
86
  * Version configuration. Determines how version is made available:
77
87
  *
@@ -79,12 +89,23 @@ interface RunOptions {
79
89
  * - `object`: Advanced configuration with version value and mode
80
90
  * - `value`: The version string to display
81
91
  * - `mode`: "command" | "option" | "both" (default: "option")
92
+ * - `group`: Group label for version command in help output (only
93
+ * when mode is "command" or "both")
82
94
  *
83
95
  * When not provided, version functionality is disabled.
84
96
  */
85
97
  readonly version?: string | {
86
98
  readonly value: string;
87
- readonly mode?: "command" | "option" | "both";
99
+ readonly mode: "command" | "both";
100
+ /**
101
+ * Group label for the version command in help output.
102
+ * @since 0.10.0
103
+ */
104
+ readonly group?: string;
105
+ } | {
106
+ readonly value: string;
107
+ readonly mode?: "option";
108
+ readonly group?: never;
88
109
  };
89
110
  /**
90
111
  * Completion configuration. Determines how shell completion is made available:
@@ -159,7 +180,16 @@ interface RunOptions {
159
180
  }
160
181
  type CompletionHelpVisibility = "singular" | "plural" | "both" | "none";
161
182
  type CompletionOptionsBase = {
162
- readonly mode?: "command" | "option" | "both";
183
+ readonly mode?: "command" | "both";
184
+ /**
185
+ * Group label for the completion command in help output.
186
+ * @since 0.10.0
187
+ */
188
+ readonly group?: string;
189
+ readonly shells?: Record<string, ShellCompletion>;
190
+ } | {
191
+ readonly mode: "option";
192
+ readonly group?: never;
163
193
  readonly shells?: Record<string, ShellCompletion>;
164
194
  };
165
195
  type CompletionOptionsBoth = CompletionOptionsBase & {
package/dist/run.js CHANGED
@@ -32,46 +32,69 @@ function runImpl(parserOrProgram, options = {}) {
32
32
  };
33
33
  } else parser = parserOrProgram;
34
34
  const { programName = programNameFromProgram ?? path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, showDefault, showChoices, 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;
35
- const helpConfig = help ? {
35
+ const helpConfig = help ? typeof help === "string" ? {
36
36
  mode: help,
37
37
  onShow: () => process.exit(0)
38
- } : void 0;
39
- const versionConfig = version ? {
40
- mode: typeof version === "string" ? "option" : version.mode ?? "option",
41
- value: typeof version === "string" ? version : version.value,
38
+ } : {
39
+ mode: help.mode,
40
+ group: help.group,
42
41
  onShow: () => process.exit(0)
43
42
  } : void 0;
43
+ const versionConfig = (() => {
44
+ if (!version) return void 0;
45
+ if (typeof version === "string") return {
46
+ mode: "option",
47
+ value: version,
48
+ onShow: () => process.exit(0)
49
+ };
50
+ const mode = version.mode ?? "option";
51
+ if (mode === "command" || mode === "both") return {
52
+ mode,
53
+ value: version.value,
54
+ group: version.group,
55
+ onShow: () => process.exit(0)
56
+ };
57
+ return {
58
+ mode,
59
+ value: version.value,
60
+ onShow: () => process.exit(0)
61
+ };
62
+ })();
44
63
  const completionConfig = (() => {
45
64
  if (!completion) return void 0;
65
+ const onShow = () => process.exit(0);
46
66
  if (typeof completion === "string") return {
47
67
  mode: completion,
48
- shells: void 0,
49
68
  name: "both",
50
69
  helpVisibility: "both",
51
- onShow: () => process.exit(0)
70
+ onShow
52
71
  };
53
72
  const mode = completion.mode ?? "both";
54
73
  const shells = completion.shells;
74
+ const cGroup = completion.group;
55
75
  if (completion.name === "singular") return {
56
76
  mode,
57
77
  shells,
78
+ ...cGroup != null && { group: cGroup },
58
79
  name: "singular",
59
80
  helpVisibility: completion.helpVisibility ?? "singular",
60
- onShow: () => process.exit(0)
81
+ onShow
61
82
  };
62
83
  if (completion.name === "plural") return {
63
84
  mode,
64
85
  shells,
86
+ ...cGroup != null && { group: cGroup },
65
87
  name: "plural",
66
88
  helpVisibility: completion.helpVisibility ?? "plural",
67
- onShow: () => process.exit(0)
89
+ onShow
68
90
  };
69
91
  return {
70
92
  mode,
71
93
  shells,
94
+ ...cGroup != null && { group: cGroup },
72
95
  name: "both",
73
96
  helpVisibility: completion.helpVisibility ?? "both",
74
- onShow: () => process.exit(0)
97
+ onShow
75
98
  };
76
99
  })();
77
100
  return runParser(parser, programName, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/run",
3
- "version": "0.10.0-dev.374+981b7fab",
3
+ "version": "0.10.0-dev.375+fffd225e",
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": "0.10.0-dev.374+981b7fab"
73
+ "@optique/core": "0.10.0-dev.375+fffd225e"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.19.9",