@optique/run 0.3.0-dev.42 → 0.3.0-dev.43
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 +12 -3
- package/dist/run.d.cts +17 -4
- package/dist/run.d.ts +17 -4
- package/dist/run.js +12 -3
- package/package.json +1 -1
package/dist/run.cjs
CHANGED
|
@@ -54,13 +54,22 @@ const node_process = require_rolldown_runtime.__toESM(require("node:process"));
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
function run(parser, options = {}) {
|
|
57
|
-
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, help
|
|
57
|
+
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, help, version, aboveError = "usage", errorExitCode = 1 } = options;
|
|
58
|
+
const helpConfig = help ? {
|
|
59
|
+
mode: help,
|
|
60
|
+
onShow: () => node_process.default.exit(0)
|
|
61
|
+
} : void 0;
|
|
62
|
+
const versionConfig = version ? {
|
|
63
|
+
mode: typeof version === "string" ? "option" : version.mode ?? "option",
|
|
64
|
+
value: typeof version === "string" ? version : version.value,
|
|
65
|
+
onShow: () => node_process.default.exit(0)
|
|
66
|
+
} : void 0;
|
|
58
67
|
return (0, __optique_core_facade.run)(parser, programName, args, {
|
|
59
68
|
colors,
|
|
60
69
|
maxWidth,
|
|
61
|
-
help,
|
|
70
|
+
help: helpConfig,
|
|
71
|
+
version: versionConfig,
|
|
62
72
|
aboveError,
|
|
63
|
-
onHelp: node_process.default.exit,
|
|
64
73
|
onError() {
|
|
65
74
|
return node_process.default.exit(errorExitCode);
|
|
66
75
|
}
|
package/dist/run.d.cts
CHANGED
|
@@ -32,16 +32,29 @@ interface RunOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
readonly maxWidth?: number;
|
|
34
34
|
/**
|
|
35
|
-
* Determines how help
|
|
35
|
+
* Help configuration. Determines how help is made available:
|
|
36
36
|
*
|
|
37
37
|
* - `"command"`: Only the `help` subcommand is available
|
|
38
38
|
* - `"option"`: Only the `--help` option is available
|
|
39
39
|
* - `"both"`: Both `help` subcommand and `--help` option are available
|
|
40
|
-
* - `"none"`: No help functionality is provided
|
|
41
40
|
*
|
|
42
|
-
*
|
|
41
|
+
* When not provided, help functionality is disabled.
|
|
43
42
|
*/
|
|
44
|
-
readonly help?: "command" | "option" | "both"
|
|
43
|
+
readonly help?: "command" | "option" | "both";
|
|
44
|
+
/**
|
|
45
|
+
* Version configuration. Determines how version is made available:
|
|
46
|
+
*
|
|
47
|
+
* - `string`: Version value with default `"option"` mode (--version only)
|
|
48
|
+
* - `object`: Advanced configuration with version value and mode
|
|
49
|
+
* - `value`: The version string to display
|
|
50
|
+
* - `mode`: "command" | "option" | "both" (default: "option")
|
|
51
|
+
*
|
|
52
|
+
* When not provided, version functionality is disabled.
|
|
53
|
+
*/
|
|
54
|
+
readonly version?: string | {
|
|
55
|
+
readonly value: string;
|
|
56
|
+
readonly mode?: "command" | "option" | "both";
|
|
57
|
+
};
|
|
45
58
|
/**
|
|
46
59
|
* What to display above error messages:
|
|
47
60
|
*
|
package/dist/run.d.ts
CHANGED
|
@@ -32,16 +32,29 @@ interface RunOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
readonly maxWidth?: number;
|
|
34
34
|
/**
|
|
35
|
-
* Determines how help
|
|
35
|
+
* Help configuration. Determines how help is made available:
|
|
36
36
|
*
|
|
37
37
|
* - `"command"`: Only the `help` subcommand is available
|
|
38
38
|
* - `"option"`: Only the `--help` option is available
|
|
39
39
|
* - `"both"`: Both `help` subcommand and `--help` option are available
|
|
40
|
-
* - `"none"`: No help functionality is provided
|
|
41
40
|
*
|
|
42
|
-
*
|
|
41
|
+
* When not provided, help functionality is disabled.
|
|
43
42
|
*/
|
|
44
|
-
readonly help?: "command" | "option" | "both"
|
|
43
|
+
readonly help?: "command" | "option" | "both";
|
|
44
|
+
/**
|
|
45
|
+
* Version configuration. Determines how version is made available:
|
|
46
|
+
*
|
|
47
|
+
* - `string`: Version value with default `"option"` mode (--version only)
|
|
48
|
+
* - `object`: Advanced configuration with version value and mode
|
|
49
|
+
* - `value`: The version string to display
|
|
50
|
+
* - `mode`: "command" | "option" | "both" (default: "option")
|
|
51
|
+
*
|
|
52
|
+
* When not provided, version functionality is disabled.
|
|
53
|
+
*/
|
|
54
|
+
readonly version?: string | {
|
|
55
|
+
readonly value: string;
|
|
56
|
+
readonly mode?: "command" | "option" | "both";
|
|
57
|
+
};
|
|
45
58
|
/**
|
|
46
59
|
* What to display above error messages:
|
|
47
60
|
*
|
package/dist/run.js
CHANGED
|
@@ -53,13 +53,22 @@ import process from "node:process";
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
function run(parser, options = {}) {
|
|
56
|
-
const { programName = path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, help
|
|
56
|
+
const { programName = path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, help, version, aboveError = "usage", errorExitCode = 1 } = options;
|
|
57
|
+
const helpConfig = help ? {
|
|
58
|
+
mode: help,
|
|
59
|
+
onShow: () => process.exit(0)
|
|
60
|
+
} : void 0;
|
|
61
|
+
const versionConfig = version ? {
|
|
62
|
+
mode: typeof version === "string" ? "option" : version.mode ?? "option",
|
|
63
|
+
value: typeof version === "string" ? version : version.value,
|
|
64
|
+
onShow: () => process.exit(0)
|
|
65
|
+
} : void 0;
|
|
57
66
|
return run$1(parser, programName, args, {
|
|
58
67
|
colors,
|
|
59
68
|
maxWidth,
|
|
60
|
-
help,
|
|
69
|
+
help: helpConfig,
|
|
70
|
+
version: versionConfig,
|
|
61
71
|
aboveError,
|
|
62
|
-
onHelp: process.exit,
|
|
63
72
|
onError() {
|
|
64
73
|
return process.exit(errorExitCode);
|
|
65
74
|
}
|