@shell-shock/core 0.17.21 → 0.17.23
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/README.md +16 -7
- package/dist/api.cjs +4 -5
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +2 -2
- package/dist/command-B6KYexlV.d.mts +308 -0
- package/dist/command-B6KYexlV.d.mts.map +1 -0
- package/dist/command-CtfR7hKM.d.cts +308 -0
- package/dist/command-CtfR7hKM.d.cts.map +1 -0
- package/dist/components/command-validation-logic.cjs +153 -216
- package/dist/components/command-validation-logic.d.cts +2 -1
- package/dist/components/command-validation-logic.d.cts.map +1 -1
- package/dist/components/command-validation-logic.d.mts +2 -1
- package/dist/components/command-validation-logic.mjs +153 -214
- package/dist/components/docs.cjs +6 -364
- package/dist/components/docs.d.cts +2 -3
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +2 -3
- package/dist/components/docs.mjs +2 -356
- package/dist/components/exec-builtin.cjs +63 -100
- package/dist/components/exec-builtin.d.cts +1 -2
- package/dist/components/exec-builtin.d.cts.map +1 -1
- package/dist/components/exec-builtin.d.mts +1 -2
- package/dist/components/exec-builtin.mjs +7 -41
- package/dist/components/helpers.cjs +2 -52
- package/dist/components/helpers.d.cts +2 -1
- package/dist/components/helpers.d.cts.map +1 -1
- package/dist/components/helpers.d.mts +2 -1
- package/dist/components/helpers.mjs +2 -50
- package/dist/components/index.cjs +7 -23
- package/dist/components/index.mjs +9 -9
- package/dist/components/options-parser-logic.cjs +198 -420
- package/dist/components/options-parser-logic.d.cts +2 -5
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +2 -5
- package/dist/components/options-parser-logic.mjs +192 -407
- package/dist/components/state-builtin.cjs +106 -164
- package/dist/components/state-builtin.d.cts +1 -2
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts +1 -2
- package/dist/components/state-builtin.mjs +12 -68
- package/dist/components/usage.cjs +4 -48
- package/dist/components/usage.d.cts +1 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.d.mts +1 -2
- package/dist/components/usage.mjs +4 -46
- package/dist/components/utils-builtin.cjs +77 -144
- package/dist/components/utils-builtin.d.cts +1 -2
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +1 -2
- package/dist/components/utils-builtin.mjs +9 -74
- package/dist/config-BIF9mEz0.d.cts +157 -0
- package/dist/config-BIF9mEz0.d.cts.map +1 -0
- package/dist/config-CnNYdfsL.d.mts +157 -0
- package/dist/config-CnNYdfsL.d.mts.map +1 -0
- package/dist/config.cjs +24 -58
- package/dist/config.d.cts +1 -2
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +1 -2
- package/dist/config.mjs +23 -55
- package/dist/{plugin-utils/context-helpers.mjs → context-helpers-D3EJxwbq.mjs} +5 -83
- package/dist/context-helpers-D3EJxwbq.mjs.map +1 -0
- package/dist/{plugin-utils/context-helpers.cjs → context-helpers-_wUuFRB8.cjs} +63 -92
- package/dist/contexts/command.cjs +3 -9
- package/dist/contexts/command.d.cts +1 -2
- package/dist/contexts/command.d.cts.map +1 -1
- package/dist/contexts/command.d.mts +1 -2
- package/dist/contexts/command.mjs +2 -7
- package/dist/contexts/index.cjs +19 -1
- package/dist/contexts/index.d.cts +2 -1
- package/dist/contexts/index.d.mts +2 -1
- package/dist/contexts/index.mjs +2 -1
- package/dist/contexts/options.cjs +7 -30
- package/dist/contexts/options.d.cts +1 -2
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +1 -2
- package/dist/contexts/options.mjs +7 -27
- package/dist/contexts/power-plant.cjs +19 -0
- package/dist/contexts/power-plant.d.cts +2 -0
- package/dist/contexts/power-plant.d.mts +2 -0
- package/dist/contexts/power-plant.mjs +5 -0
- package/dist/docs-C6ZvsVMu.cjs +278 -0
- package/dist/docs-CGQ2HtEY.mjs +249 -0
- package/dist/docs-CGQ2HtEY.mjs.map +1 -0
- package/dist/engine.cjs +5 -39
- package/dist/engine.d.cts +1 -2
- package/dist/engine.d.cts.map +1 -1
- package/dist/engine.d.mts +1 -2
- package/dist/engine.mjs +4 -37
- package/dist/generator.cjs +68 -0
- package/dist/generator.d.cts +15 -0
- package/dist/generator.d.cts.map +1 -0
- package/dist/generator.d.mts +15 -0
- package/dist/generator.d.mts.map +1 -0
- package/dist/generator.mjs +66 -0
- package/dist/generator.mjs.map +1 -0
- package/dist/{helpers/get-framework.cjs → get-framework-CxZc2krd.cjs} +7 -8
- package/dist/{helpers/get-framework.mjs → get-framework-Dlqz2hVZ.mjs} +3 -8
- package/dist/get-framework-Dlqz2hVZ.mjs.map +1 -0
- package/dist/helpers/power-plant.cjs +102 -0
- package/dist/helpers/power-plant.d.cts +61 -0
- package/dist/helpers/power-plant.d.cts.map +1 -0
- package/dist/helpers/power-plant.d.mts +61 -0
- package/dist/helpers/power-plant.d.mts.map +1 -0
- package/dist/helpers/power-plant.mjs +99 -0
- package/dist/helpers/power-plant.mjs.map +1 -0
- package/dist/index-D4klH_pj.d.mts +2 -0
- package/dist/index-DYOBadKY.d.cts +2 -0
- package/dist/index.cjs +1 -37
- package/dist/index.d.cts +4 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -6
- package/dist/index.mjs +0 -35
- package/dist/package-B7Vu265G.mjs +6 -0
- package/dist/package-B7Vu265G.mjs.map +1 -0
- package/dist/{package.cjs → package-BLC4qc8t.cjs} +2 -4
- package/dist/plugin-B-hM2twc.mjs +1458 -0
- package/dist/plugin-B-hM2twc.mjs.map +1 -0
- package/dist/plugin-Bhfq0DMC.cjs +1490 -0
- package/dist/plugin-utils/index.cjs +359 -26
- package/dist/plugin-utils/index.d.cts +273 -9
- package/dist/plugin-utils/index.d.cts.map +1 -0
- package/dist/plugin-utils/index.d.mts +273 -9
- package/dist/plugin-utils/index.d.mts.map +1 -0
- package/dist/plugin-utils/index.mjs +346 -10
- package/dist/plugin-utils/index.mjs.map +1 -0
- package/dist/plugin.cjs +3 -496
- package/dist/plugin.d.cts +1 -3
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +1 -3
- package/dist/plugin.mjs +2 -491
- package/dist/power-plant-LgxcvlMN.d.cts +4 -0
- package/dist/power-plant-LgxcvlMN.d.mts +4 -0
- package/dist/reflect-CSiffeL9.cjs +27 -0
- package/dist/reflect-DXKSFgvS.mjs +23 -0
- package/dist/reflect-DXKSFgvS.mjs.map +1 -0
- package/dist/schemas/env.cjs +91 -0
- package/dist/schemas/env.d.cts +145 -0
- package/dist/schemas/env.d.cts.map +1 -0
- package/dist/schemas/env.d.mts +145 -0
- package/dist/{types → schemas}/env.d.mts.map +1 -1
- package/dist/schemas/env.mjs +91 -0
- package/dist/schemas/index.cjs +4 -0
- package/dist/schemas/index.d.cts +2 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +3 -0
- package/dist/types/command.cjs +0 -402
- package/dist/types/command.d.cts +2 -309
- package/dist/types/command.d.mts +2 -309
- package/dist/types/command.mjs +1 -368
- package/dist/types/config.cjs +0 -175
- package/dist/types/config.d.cts +2 -126
- package/dist/types/config.d.mts +2 -126
- package/dist/types/config.mjs +1 -164
- package/dist/types/context.cjs +0 -45
- package/dist/types/context.d.cts +2 -31
- package/dist/types/context.d.mts +2 -31
- package/dist/types/context.mjs +1 -41
- package/dist/types/index.cjs +3 -53
- package/dist/types/index.d.cts +4 -5
- package/dist/types/index.d.mts +4 -5
- package/dist/types/index.mjs +4 -5
- package/package.json +106 -42
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/api.cjs.map +0 -1
- package/dist/components/command-validation-logic.cjs.map +0 -1
- package/dist/components/docs.cjs.map +0 -1
- package/dist/components/docs.mjs.map +0 -1
- package/dist/components/exec-builtin.cjs.map +0 -1
- package/dist/components/helpers.cjs.map +0 -1
- package/dist/components/options-parser-logic.cjs.map +0 -1
- package/dist/components/state-builtin.cjs.map +0 -1
- package/dist/components/usage.cjs.map +0 -1
- package/dist/components/utils-builtin.cjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/contexts/command.cjs.map +0 -1
- package/dist/contexts/options.cjs.map +0 -1
- package/dist/engine.cjs.map +0 -1
- package/dist/helpers/automd.cjs +0 -193
- package/dist/helpers/automd.cjs.map +0 -1
- package/dist/helpers/automd.mjs +0 -190
- package/dist/helpers/automd.mjs.map +0 -1
- package/dist/helpers/docs-helpers.cjs +0 -24
- package/dist/helpers/docs-helpers.cjs.map +0 -1
- package/dist/helpers/docs-helpers.mjs +0 -24
- package/dist/helpers/docs-helpers.mjs.map +0 -1
- package/dist/helpers/get-framework.cjs.map +0 -1
- package/dist/helpers/get-framework.mjs.map +0 -1
- package/dist/helpers/paths.cjs +0 -137
- package/dist/helpers/paths.cjs.map +0 -1
- package/dist/helpers/paths.mjs +0 -134
- package/dist/helpers/paths.mjs.map +0 -1
- package/dist/helpers/persistence.cjs +0 -114
- package/dist/helpers/persistence.cjs.map +0 -1
- package/dist/helpers/persistence.mjs +0 -113
- package/dist/helpers/persistence.mjs.map +0 -1
- package/dist/helpers/update-package-json.cjs +0 -65
- package/dist/helpers/update-package-json.cjs.map +0 -1
- package/dist/helpers/update-package-json.mjs +0 -64
- package/dist/helpers/update-package-json.mjs.map +0 -1
- package/dist/helpers/utilities.cjs +0 -95
- package/dist/helpers/utilities.cjs.map +0 -1
- package/dist/helpers/utilities.mjs +0 -94
- package/dist/helpers/utilities.mjs.map +0 -1
- package/dist/helpers/validations.cjs +0 -71
- package/dist/helpers/validations.cjs.map +0 -1
- package/dist/helpers/validations.mjs +0 -70
- package/dist/helpers/validations.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/package.cjs.map +0 -1
- package/dist/package.mjs +0 -6
- package/dist/package.mjs.map +0 -1
- package/dist/plugin-utils/compute-bin.cjs +0 -49
- package/dist/plugin-utils/compute-bin.cjs.map +0 -1
- package/dist/plugin-utils/compute-bin.d.cts +0 -13
- package/dist/plugin-utils/compute-bin.d.cts.map +0 -1
- package/dist/plugin-utils/compute-bin.d.mts +0 -13
- package/dist/plugin-utils/compute-bin.d.mts.map +0 -1
- package/dist/plugin-utils/compute-bin.mjs +0 -49
- package/dist/plugin-utils/compute-bin.mjs.map +0 -1
- package/dist/plugin-utils/context-helpers.cjs.map +0 -1
- package/dist/plugin-utils/context-helpers.d.cts +0 -106
- package/dist/plugin-utils/context-helpers.d.cts.map +0 -1
- package/dist/plugin-utils/context-helpers.d.mts +0 -106
- package/dist/plugin-utils/context-helpers.d.mts.map +0 -1
- package/dist/plugin-utils/context-helpers.mjs.map +0 -1
- package/dist/plugin-utils/deepkit.cjs +0 -70
- package/dist/plugin-utils/deepkit.cjs.map +0 -1
- package/dist/plugin-utils/deepkit.d.cts +0 -23
- package/dist/plugin-utils/deepkit.d.cts.map +0 -1
- package/dist/plugin-utils/deepkit.d.mts +0 -23
- package/dist/plugin-utils/deepkit.d.mts.map +0 -1
- package/dist/plugin-utils/deepkit.mjs +0 -69
- package/dist/plugin-utils/deepkit.mjs.map +0 -1
- package/dist/plugin-utils/description-helpers.cjs +0 -112
- package/dist/plugin-utils/description-helpers.cjs.map +0 -1
- package/dist/plugin-utils/description-helpers.d.cts +0 -44
- package/dist/plugin-utils/description-helpers.d.cts.map +0 -1
- package/dist/plugin-utils/description-helpers.d.mts +0 -44
- package/dist/plugin-utils/description-helpers.d.mts.map +0 -1
- package/dist/plugin-utils/description-helpers.mjs +0 -108
- package/dist/plugin-utils/description-helpers.mjs.map +0 -1
- package/dist/plugin-utils/get-command-tree.cjs +0 -118
- package/dist/plugin-utils/get-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/get-command-tree.d.cts +0 -36
- package/dist/plugin-utils/get-command-tree.d.cts.map +0 -1
- package/dist/plugin-utils/get-command-tree.d.mts +0 -36
- package/dist/plugin-utils/get-command-tree.d.mts.map +0 -1
- package/dist/plugin-utils/get-command-tree.mjs +0 -115
- package/dist/plugin-utils/get-command-tree.mjs.map +0 -1
- package/dist/plugin-utils/reflect.cjs +0 -54
- package/dist/plugin-utils/reflect.cjs.map +0 -1
- package/dist/plugin-utils/reflect.d.cts +0 -14
- package/dist/plugin-utils/reflect.d.cts.map +0 -1
- package/dist/plugin-utils/reflect.d.mts +0 -14
- package/dist/plugin-utils/reflect.d.mts.map +0 -1
- package/dist/plugin-utils/reflect.mjs +0 -53
- package/dist/plugin-utils/reflect.mjs.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +0 -65
- package/dist/plugin-utils/traverse-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.d.cts +0 -22
- package/dist/plugin-utils/traverse-command-tree.d.cts.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.d.mts +0 -22
- package/dist/plugin-utils/traverse-command-tree.d.mts.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +0 -63
- package/dist/plugin-utils/traverse-command-tree.mjs.map +0 -1
- package/dist/plugin-utils/type-checks.cjs +0 -222
- package/dist/plugin-utils/type-checks.cjs.map +0 -1
- package/dist/plugin-utils/type-checks.d.cts +0 -41
- package/dist/plugin-utils/type-checks.d.cts.map +0 -1
- package/dist/plugin-utils/type-checks.d.mts +0 -41
- package/dist/plugin-utils/type-checks.d.mts.map +0 -1
- package/dist/plugin-utils/type-checks.mjs +0 -218
- package/dist/plugin-utils/type-checks.mjs.map +0 -1
- package/dist/plugin.cjs.map +0 -1
- package/dist/plugin.mjs.map +0 -1
- package/dist/resolver/deepkit.cjs +0 -110
- package/dist/resolver/deepkit.cjs.map +0 -1
- package/dist/resolver/deepkit.mjs +0 -109
- package/dist/resolver/deepkit.mjs.map +0 -1
- package/dist/resolver/helpers.cjs +0 -184
- package/dist/resolver/helpers.cjs.map +0 -1
- package/dist/resolver/helpers.mjs +0 -180
- package/dist/resolver/helpers.mjs.map +0 -1
- package/dist/resolver/resolve.cjs +0 -473
- package/dist/resolver/resolve.cjs.map +0 -1
- package/dist/resolver/resolve.mjs +0 -473
- package/dist/resolver/resolve.mjs.map +0 -1
- package/dist/types/command.cjs.map +0 -1
- package/dist/types/command.d.cts.map +0 -1
- package/dist/types/command.d.mts.map +0 -1
- package/dist/types/command.mjs.map +0 -1
- package/dist/types/config.cjs.map +0 -1
- package/dist/types/config.d.cts.map +0 -1
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs.map +0 -1
- package/dist/types/context.cjs.map +0 -1
- package/dist/types/context.d.cts.map +0 -1
- package/dist/types/context.d.mts.map +0 -1
- package/dist/types/context.mjs.map +0 -1
- package/dist/types/env.cjs +0 -53
- package/dist/types/env.cjs.map +0 -1
- package/dist/types/env.d.cts +0 -71
- package/dist/types/env.d.cts.map +0 -1
- package/dist/types/env.d.mts +0 -71
- package/dist/types/env.mjs +0 -51
- /package/dist/{types → schemas}/env.mjs.map +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDynamicPathSegmentName, isDynamicPathSegment } from "../
|
|
1
|
+
import { a as getDynamicPathSegmentName, c as isDynamicPathSegment } from "../context-helpers-D3EJxwbq.mjs";
|
|
2
2
|
import { computedOptions } from "../contexts/options.mjs";
|
|
3
3
|
import { BooleanInputParserLogic, CommandParameterType } from "./helpers.mjs";
|
|
4
4
|
import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
|
|
@@ -6,81 +6,44 @@ import { For, Show, code, computed } from "@alloy-js/core";
|
|
|
6
6
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
7
7
|
import { constantCase } from "@stryke/string-format/constant-case";
|
|
8
8
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
9
|
-
import { Spacing } from "@
|
|
9
|
+
import { Spacing } from "@power-plant/alloy-js/core/components/spacing";
|
|
10
10
|
import { ElseClause, ElseIfClause, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
11
11
|
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
12
12
|
|
|
13
13
|
//#region src/components/options-parser-logic.tsx
|
|
14
|
-
function __assignType(fn, args) {
|
|
15
|
-
fn.__type = args;
|
|
16
|
-
return fn;
|
|
17
|
-
}
|
|
18
|
-
const __ΩDynamicSegmentsParserLogicProps = [
|
|
19
|
-
"CommandTree",
|
|
20
|
-
"command",
|
|
21
|
-
"The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.",
|
|
22
|
-
"isCaseSensitive",
|
|
23
|
-
"Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
24
|
-
"DynamicSegmentsParserLogicProps",
|
|
25
|
-
"P\"w!4\"?#)4$?%Mw&y"
|
|
26
|
-
];
|
|
27
14
|
function DynamicSegmentsParserLogic(props) {
|
|
28
15
|
const { command } = props;
|
|
29
16
|
return createComponent(For, {
|
|
30
17
|
get each() {
|
|
31
18
|
return command.segments ?? [];
|
|
32
19
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}), [
|
|
59
|
-
"segment",
|
|
60
|
-
"index",
|
|
61
|
-
"",
|
|
62
|
-
"P\"2!\"2\"\"/#"
|
|
63
|
-
]);
|
|
64
|
-
}
|
|
20
|
+
children: (segment, index) => createComponent(Show, {
|
|
21
|
+
get when() {
|
|
22
|
+
return isDynamicPathSegment(segment);
|
|
23
|
+
},
|
|
24
|
+
get children() {
|
|
25
|
+
return [
|
|
26
|
+
createComponent(VarDeclaration, {
|
|
27
|
+
"let": true,
|
|
28
|
+
get name() {
|
|
29
|
+
return camelCase(getDynamicPathSegmentName(segment));
|
|
30
|
+
},
|
|
31
|
+
type: "string | undefined"
|
|
32
|
+
}),
|
|
33
|
+
createIntrinsic("hbr", {}),
|
|
34
|
+
createComponent(IfStatement, {
|
|
35
|
+
condition: code`args.length > ${2 + index} && args[${2 + index}]`,
|
|
36
|
+
get children() {
|
|
37
|
+
return code`${camelCase(getDynamicPathSegmentName(segment))} = args[${2 + index}];`;
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
createIntrinsic("hbr", {}),
|
|
41
|
+
createIntrinsic("hbr", {})
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
})
|
|
65
45
|
});
|
|
66
46
|
}
|
|
67
|
-
DynamicSegmentsParserLogic.__type = [
|
|
68
|
-
() => __ΩDynamicSegmentsParserLogicProps,
|
|
69
|
-
"props",
|
|
70
|
-
"DynamicSegmentsParserLogic",
|
|
71
|
-
"Pn!2\"\"/#"
|
|
72
|
-
];
|
|
73
|
-
const __ΩArgumentsParserLogicProps = [
|
|
74
|
-
"CommandTree",
|
|
75
|
-
"command",
|
|
76
|
-
"The command to generate the positional parameters parser logic for.",
|
|
77
|
-
"appSpecificEnvPrefix",
|
|
78
|
-
"The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",
|
|
79
|
-
"isCaseSensitive",
|
|
80
|
-
"Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
81
|
-
"ArgumentsParserLogicProps",
|
|
82
|
-
"P\"w!4\"?#&4$?%)4&?'Mw(y"
|
|
83
|
-
];
|
|
84
47
|
function ArgumentsParserLogic(props) {
|
|
85
48
|
const { command, appSpecificEnvPrefix, isCaseSensitive } = props;
|
|
86
49
|
return createComponent(Show, {
|
|
@@ -94,15 +57,7 @@ function ArgumentsParserLogic(props) {
|
|
|
94
57
|
name: "optionsIndex",
|
|
95
58
|
type: "number",
|
|
96
59
|
get initializer() {
|
|
97
|
-
return code`Math.max(0, args.slice(${command.segments.length + 1}).findIndex(arg => arg.startsWith("-") && /^(${Object.values(command.options ?? {}).map(
|
|
98
|
-
"a",
|
|
99
|
-
"",
|
|
100
|
-
"P\"2!\"/\""
|
|
101
|
-
])).join("|")}`, [
|
|
102
|
-
"option",
|
|
103
|
-
"",
|
|
104
|
-
"P\"2!\"/\""
|
|
105
|
-
])).join("|")})=?.*$/.test(arg${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}))) + ${command.segments.length + 1};`;
|
|
60
|
+
return code`Math.max(0, args.slice(${command.segments.length + 1}).findIndex(arg => arg.startsWith("-") && /^(${Object.values(command.options ?? {}).map((option) => `${isCaseSensitive || option.name.length === 1 ? option.name : option.name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map((a) => (isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")) === "?" ? "\\?" : isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")).join("|")}`).join("|")})=?.*$/.test(arg${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}))) + ${command.segments.length + 1};`;
|
|
106
61
|
}
|
|
107
62
|
}),
|
|
108
63
|
createComponent(Spacing, {}),
|
|
@@ -111,15 +66,7 @@ function ArgumentsParserLogic(props) {
|
|
|
111
66
|
name: "argsIndex",
|
|
112
67
|
type: "number",
|
|
113
68
|
get initializer() {
|
|
114
|
-
return code`optionsIndex > ${command.segments.length + 1} ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith("-") && /^(${Object.values(command.options ?? {}).map(
|
|
115
|
-
"a",
|
|
116
|
-
"",
|
|
117
|
-
"P\"2!\"/\""
|
|
118
|
-
])).join("|")}`, [
|
|
119
|
-
"option",
|
|
120
|
-
"",
|
|
121
|
-
"P\"2!\"/\""
|
|
122
|
-
])).join("|")})=?.*$/.test(arg${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}))) + ${command.segments.length + 1});`;
|
|
69
|
+
return code`optionsIndex > ${command.segments.length + 1} ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith("-") && /^(${Object.values(command.options ?? {}).map((option) => `${isCaseSensitive || option.name.length === 1 ? option.name : option.name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map((a) => (isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")) === "?" ? "\\?" : isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")).join("|")}`).join("|")})=?.*$/.test(arg${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}))) + ${command.segments.length + 1});`;
|
|
123
70
|
}
|
|
124
71
|
}),
|
|
125
72
|
createComponent(Spacing, {}),
|
|
@@ -128,136 +75,119 @@ function ArgumentsParserLogic(props) {
|
|
|
128
75
|
return command.args ?? [];
|
|
129
76
|
},
|
|
130
77
|
hardline: true,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
78
|
+
children: (arg, index) => [
|
|
79
|
+
createComponent(Show, {
|
|
80
|
+
get when() {
|
|
81
|
+
return isSetString(arg.env) || arg.default !== void 0 || arg.variadic;
|
|
82
|
+
},
|
|
83
|
+
get fallback() {
|
|
84
|
+
return [
|
|
85
|
+
memo(() => code`let ${camelCase(arg.name)}!: `),
|
|
86
|
+
createComponent(CommandParameterType, { parameter: arg }),
|
|
87
|
+
code`; `
|
|
88
|
+
];
|
|
89
|
+
},
|
|
90
|
+
get children() {
|
|
91
|
+
return createComponent(VarDeclaration, {
|
|
92
|
+
"let": true,
|
|
93
|
+
get name() {
|
|
94
|
+
return camelCase(arg.name);
|
|
95
|
+
},
|
|
96
|
+
get type() {
|
|
97
|
+
return createComponent(CommandParameterType, { parameter: arg });
|
|
98
|
+
},
|
|
99
|
+
get initializer() {
|
|
100
|
+
return [
|
|
101
|
+
code` ( `,
|
|
102
|
+
createComponent(Show, {
|
|
103
|
+
get when() {
|
|
104
|
+
return isSetString(arg.env);
|
|
105
|
+
},
|
|
106
|
+
get children() {
|
|
107
|
+
return code`env.${appSpecificEnvPrefix}_${constantCase(String(arg.env))} ?? `;
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
createComponent(Show, {
|
|
111
|
+
get when() {
|
|
112
|
+
return arg.default !== void 0 && (!arg.variadic || arg.default.length > 0);
|
|
113
|
+
},
|
|
114
|
+
get fallback() {
|
|
115
|
+
return createComponent(Show, {
|
|
116
|
+
get when() {
|
|
117
|
+
return arg.variadic;
|
|
118
|
+
},
|
|
119
|
+
fallback: code`undefined`,
|
|
120
|
+
children: code`[]`
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
get children() {
|
|
124
|
+
return createComponent(Show, {
|
|
125
|
+
get when() {
|
|
126
|
+
return arg.variadic;
|
|
127
|
+
},
|
|
128
|
+
get fallback() {
|
|
129
|
+
return arg.type === "string" ? code`"${arg.default}"` : code`${arg.default}`;
|
|
130
|
+
},
|
|
131
|
+
get children() {
|
|
132
|
+
return code`[${arg.default?.map((value) => arg.type === "string" ? `"${value}"` : value).join(", ")}]`;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
code`) as `,
|
|
138
|
+
createComponent(CommandParameterType, { parameter: arg }),
|
|
139
|
+
code`; `
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
createComponent(Spacing, {}),
|
|
146
|
+
createComponent(IfStatement, {
|
|
147
|
+
condition: code`argsIndex + ${index} < args.length && argsIndex + ${index} !== optionsIndex`,
|
|
148
|
+
get children() {
|
|
149
|
+
return [
|
|
150
|
+
memo(() => code`${camelCase(arg.name)} = `),
|
|
151
|
+
createComponent(Show, {
|
|
152
|
+
get when() {
|
|
153
|
+
return arg.type === "string" || arg.type === "number";
|
|
149
154
|
},
|
|
150
|
-
get
|
|
151
|
-
return createComponent(
|
|
155
|
+
get fallback() {
|
|
156
|
+
return createComponent(BooleanInputParserLogic, { name: `args[argsIndex + ${index}] ` });
|
|
152
157
|
},
|
|
153
|
-
get
|
|
154
|
-
return
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return arg.variadic;
|
|
172
|
-
},
|
|
173
|
-
fallback: code`undefined`,
|
|
174
|
-
children: code`[]`
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
get children() {
|
|
178
|
-
return createComponent(Show, {
|
|
179
|
-
get when() {
|
|
180
|
-
return arg.variadic;
|
|
181
|
-
},
|
|
182
|
-
get fallback() {
|
|
183
|
-
return arg.type === "string" ? code`"${arg.default}"` : code`${arg.default}`;
|
|
184
|
-
},
|
|
185
|
-
get children() {
|
|
186
|
-
return code`[${arg.default?.map(__assignType((value) => arg.type === "string" ? `"${value}"` : value, [
|
|
187
|
-
"value",
|
|
188
|
-
"",
|
|
189
|
-
"P\"2!\"/\""
|
|
190
|
-
])).join(", ")}]`;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}),
|
|
195
|
-
code`) as `,
|
|
196
|
-
createComponent(CommandParameterType, { parameter: arg }),
|
|
197
|
-
code`; `
|
|
198
|
-
];
|
|
158
|
+
get children() {
|
|
159
|
+
return createComponent(Show, {
|
|
160
|
+
get when() {
|
|
161
|
+
return arg.variadic;
|
|
162
|
+
},
|
|
163
|
+
get fallback() {
|
|
164
|
+
return createComponent(Show, {
|
|
165
|
+
get when() {
|
|
166
|
+
return arg.type === "number";
|
|
167
|
+
},
|
|
168
|
+
fallback: code`args[argsIndex + ${index}] `,
|
|
169
|
+
children: code`Number(args[argsIndex + ${index}]) `
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
get children() {
|
|
173
|
+
return code`args.slice(argsIndex + ${index}, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${command.args.length - index}).join(" ").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean)`;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
199
176
|
}
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
createComponent(Show, {
|
|
210
|
-
get when() {
|
|
211
|
-
return arg.type === "string" || arg.type === "number";
|
|
212
|
-
},
|
|
213
|
-
get fallback() {
|
|
214
|
-
return createComponent(BooleanInputParserLogic, { name: `args[argsIndex + ${index}] ` });
|
|
215
|
-
},
|
|
216
|
-
get children() {
|
|
217
|
-
return createComponent(Show, {
|
|
218
|
-
get when() {
|
|
219
|
-
return arg.variadic;
|
|
220
|
-
},
|
|
221
|
-
get fallback() {
|
|
222
|
-
return createComponent(Show, {
|
|
223
|
-
get when() {
|
|
224
|
-
return arg.type === "number";
|
|
225
|
-
},
|
|
226
|
-
fallback: code`args[argsIndex + ${index}] `,
|
|
227
|
-
children: code`Number(args[argsIndex + ${index}]) `
|
|
228
|
-
});
|
|
229
|
-
},
|
|
230
|
-
get children() {
|
|
231
|
-
return code`args.slice(argsIndex + ${index}, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${command.args.length - index}).join(" ").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean)`;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}),
|
|
236
|
-
code` as `,
|
|
237
|
-
createComponent(CommandParameterType, { parameter: arg }),
|
|
238
|
-
code`; `
|
|
239
|
-
];
|
|
240
|
-
}
|
|
241
|
-
}),
|
|
242
|
-
createComponent(Spacing, {})
|
|
243
|
-
], [
|
|
244
|
-
"arg",
|
|
245
|
-
"index",
|
|
246
|
-
"",
|
|
247
|
-
"P\"2!\"2\"\"/#"
|
|
248
|
-
]);
|
|
249
|
-
}
|
|
177
|
+
}),
|
|
178
|
+
code` as `,
|
|
179
|
+
createComponent(CommandParameterType, { parameter: arg }),
|
|
180
|
+
code`; `
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
}),
|
|
184
|
+
createComponent(Spacing, {})
|
|
185
|
+
]
|
|
250
186
|
})
|
|
251
187
|
];
|
|
252
188
|
}
|
|
253
189
|
});
|
|
254
190
|
}
|
|
255
|
-
ArgumentsParserLogic.__type = [
|
|
256
|
-
() => __ΩArgumentsParserLogicProps,
|
|
257
|
-
"props",
|
|
258
|
-
"ArgumentsParserLogic",
|
|
259
|
-
"Pn!2\"\"/#"
|
|
260
|
-
];
|
|
261
191
|
/**
|
|
262
192
|
* The command option interface property.
|
|
263
193
|
*/
|
|
@@ -330,36 +260,12 @@ function OptionsMember({ option }) {
|
|
|
330
260
|
}
|
|
331
261
|
})];
|
|
332
262
|
}
|
|
333
|
-
OptionsMember.__type = [
|
|
334
|
-
"CommandOption",
|
|
335
|
-
"option",
|
|
336
|
-
"param0",
|
|
337
|
-
"OptionsMember",
|
|
338
|
-
"The command option interface property.",
|
|
339
|
-
"PP\"w!4\"M2#\"/$?%"
|
|
340
|
-
];
|
|
341
|
-
const __ΩOptionsMemberParserLogicProps = [
|
|
342
|
-
"name",
|
|
343
|
-
"The option name to generate the parser logic for.",
|
|
344
|
-
"CommandOption",
|
|
345
|
-
"option",
|
|
346
|
-
"The command option to generate the parser logic for.",
|
|
347
|
-
"isCaseSensitive",
|
|
348
|
-
true,
|
|
349
|
-
"Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
350
|
-
"OptionsMemberParserLogicProps",
|
|
351
|
-
"P&4!?\"\"w#4$?%)4&>'?(Mw)y"
|
|
352
|
-
];
|
|
353
263
|
/**
|
|
354
264
|
* The command option property parser logic.
|
|
355
265
|
*/
|
|
356
266
|
function OptionsMemberParserLogic(props) {
|
|
357
267
|
const { name, option, isCaseSensitive } = props;
|
|
358
|
-
const equalsRegex = `/^--?(${isCaseSensitive || name.length === 1 ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map(
|
|
359
|
-
"a",
|
|
360
|
-
"",
|
|
361
|
-
"P\"2!\"/\""
|
|
362
|
-
])).join("|")})=/`;
|
|
268
|
+
const equalsRegex = `/^--?(${isCaseSensitive || name.length === 1 ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map((a) => (isCaseSensitive || name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")) === "?" ? "\\?" : isCaseSensitive || name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")).join("|")})=/`;
|
|
363
269
|
return [createComponent(Show, {
|
|
364
270
|
get when() {
|
|
365
271
|
return option.type === "string" || option.type === "number";
|
|
@@ -407,11 +313,7 @@ function OptionsMemberParserLogic(props) {
|
|
|
407
313
|
return (option.type === "string" || option.type === "number") && option.choices && option.choices.length > 0;
|
|
408
314
|
},
|
|
409
315
|
get children() {
|
|
410
|
-
return code` as ${option.choices?.map(
|
|
411
|
-
"choice",
|
|
412
|
-
"",
|
|
413
|
-
"P\"2!\"/\""
|
|
414
|
-
])).join(" | ")} `;
|
|
316
|
+
return code` as ${option.choices?.map((choice) => isSetString(choice) ? `"${choice}"` : choice).join(" | ")} `;
|
|
415
317
|
}
|
|
416
318
|
}),
|
|
417
319
|
code`); `
|
|
@@ -446,11 +348,7 @@ function OptionsMemberParserLogic(props) {
|
|
|
446
348
|
return (option.type === "string" || option.type === "number") && option.choices && option.choices.length > 0;
|
|
447
349
|
},
|
|
448
350
|
get children() {
|
|
449
|
-
return code` as ${option.choices?.map(
|
|
450
|
-
"choice",
|
|
451
|
-
"",
|
|
452
|
-
"P\"2!\"/\""
|
|
453
|
-
])).join(" | ")} `;
|
|
351
|
+
return code` as ${option.choices?.map((choice) => isSetString(choice) ? `"${choice}"` : choice).join(" | ")} `;
|
|
454
352
|
}
|
|
455
353
|
}),
|
|
456
354
|
code`); `
|
|
@@ -487,11 +385,7 @@ function OptionsMemberParserLogic(props) {
|
|
|
487
385
|
return option.choices && option.choices.length > 0;
|
|
488
386
|
},
|
|
489
387
|
get children() {
|
|
490
|
-
return code` as ${option.choices?.map(
|
|
491
|
-
"choice",
|
|
492
|
-
"",
|
|
493
|
-
"P\"2!\"/\""
|
|
494
|
-
])).join(" | ")}`;
|
|
388
|
+
return code` as ${option.choices?.map((choice) => `"${choice}"`).join(" | ")}`;
|
|
495
389
|
}
|
|
496
390
|
}),
|
|
497
391
|
code`; `
|
|
@@ -560,11 +454,7 @@ function OptionsMemberParserLogic(props) {
|
|
|
560
454
|
return option.choices && option.choices.length > 0;
|
|
561
455
|
},
|
|
562
456
|
get children() {
|
|
563
|
-
return code` as ${option.choices?.map(
|
|
564
|
-
"choice",
|
|
565
|
-
"",
|
|
566
|
-
"P\"2!\"/\""
|
|
567
|
-
])).join(" | ")}`;
|
|
457
|
+
return code` as ${option.choices?.map((choice) => `"${choice}"`).join(" | ")}`;
|
|
568
458
|
}
|
|
569
459
|
}),
|
|
570
460
|
code`; `
|
|
@@ -674,24 +564,6 @@ function OptionsMemberParserLogic(props) {
|
|
|
674
564
|
}
|
|
675
565
|
})];
|
|
676
566
|
}
|
|
677
|
-
OptionsMemberParserLogic.__type = [
|
|
678
|
-
() => __ΩOptionsMemberParserLogicProps,
|
|
679
|
-
"props",
|
|
680
|
-
"OptionsMemberParserLogic",
|
|
681
|
-
"The command option property parser logic.",
|
|
682
|
-
"Pn!2\"\"/#?$"
|
|
683
|
-
];
|
|
684
|
-
const __ΩOptionsMemberParserConditionProps = [
|
|
685
|
-
"name",
|
|
686
|
-
"The option name to generate the parser logic for.",
|
|
687
|
-
"alias",
|
|
688
|
-
"Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
689
|
-
"isCaseSensitive",
|
|
690
|
-
true,
|
|
691
|
-
"Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
692
|
-
"OptionsMemberParserConditionProps",
|
|
693
|
-
"P&4!?\"&F4#8?$)4%>&?'Mw(y"
|
|
694
|
-
];
|
|
695
567
|
function OptionsMemberParserCondition(props) {
|
|
696
568
|
const { name, alias: aliasProp, isCaseSensitive } = props;
|
|
697
569
|
return [memo(() => code`${isCaseSensitive ? "arg.startsWith(\"--" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}" || ${isCaseSensitive ? "arg.startsWith(\"-" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}"`), createComponent(Show, {
|
|
@@ -701,33 +573,17 @@ function OptionsMemberParserCondition(props) {
|
|
|
701
573
|
get children() {
|
|
702
574
|
return createComponent(For, {
|
|
703
575
|
each: aliasProp ?? [],
|
|
704
|
-
|
|
705
|
-
return __assignType((alias) => code` || ${isCaseSensitive || alias.length === 1 ? "arg.startsWith(\"--" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive || alias.length === 1 ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}" || ${isCaseSensitive || alias.length === 1 ? "arg.startsWith(\"-" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive || alias.length === 1 ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}"`, [
|
|
706
|
-
"alias",
|
|
707
|
-
"",
|
|
708
|
-
"P\"2!\"/\""
|
|
709
|
-
]);
|
|
710
|
-
}
|
|
576
|
+
children: (alias) => code` || ${isCaseSensitive || alias.length === 1 ? "arg.startsWith(\"--" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive || alias.length === 1 ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}" || ${isCaseSensitive || alias.length === 1 ? "arg.startsWith(\"-" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive || alias.length === 1 ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}"`
|
|
711
577
|
});
|
|
712
578
|
}
|
|
713
579
|
})];
|
|
714
580
|
}
|
|
715
|
-
OptionsMemberParserCondition.__type = [
|
|
716
|
-
() => __ΩOptionsMemberParserConditionProps,
|
|
717
|
-
"props",
|
|
718
|
-
"OptionsMemberParserCondition",
|
|
719
|
-
"Pn!2\"\"/#"
|
|
720
|
-
];
|
|
721
581
|
function OptionsInterfaceDeclaration(props) {
|
|
722
582
|
const { command } = props;
|
|
723
|
-
const options = computed(() => computedOptions(Object.entries(command.options).map(
|
|
583
|
+
const options = computed(() => computedOptions(Object.entries(command.options).map(([name, option]) => ({
|
|
724
584
|
...option,
|
|
725
585
|
name
|
|
726
|
-
})
|
|
727
|
-
"param0",
|
|
728
|
-
"",
|
|
729
|
-
"P\"2!\"/\""
|
|
730
|
-
]))));
|
|
586
|
+
}))));
|
|
731
587
|
return createComponent(InterfaceDeclaration, {
|
|
732
588
|
"export": true,
|
|
733
589
|
get name() {
|
|
@@ -740,75 +596,37 @@ function OptionsInterfaceDeclaration(props) {
|
|
|
740
596
|
return Object.values(options.value);
|
|
741
597
|
},
|
|
742
598
|
hardline: true,
|
|
743
|
-
|
|
744
|
-
return __assignType((option) => createComponent(OptionsMember, { option }), [
|
|
745
|
-
"option",
|
|
746
|
-
"",
|
|
747
|
-
"P\"2!\"/\""
|
|
748
|
-
]);
|
|
749
|
-
}
|
|
599
|
+
children: (option) => createComponent(OptionsMember, { option })
|
|
750
600
|
});
|
|
751
601
|
}
|
|
752
602
|
});
|
|
753
603
|
}
|
|
754
|
-
OptionsInterfaceDeclaration.__type = [
|
|
755
|
-
"CommandTree",
|
|
756
|
-
"command",
|
|
757
|
-
"props",
|
|
758
|
-
"OptionsInterfaceDeclaration",
|
|
759
|
-
"PP\"w!4\"M2#\"/$"
|
|
760
|
-
];
|
|
761
|
-
const __ΩOptionsParserLogicProps = [
|
|
762
|
-
"appSpecificEnvPrefix",
|
|
763
|
-
"The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",
|
|
764
|
-
"isCaseSensitive",
|
|
765
|
-
true,
|
|
766
|
-
"Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
767
|
-
"OptionsParserLogicProps",
|
|
768
|
-
"P!&4!?\")4#8>$?%Mw&y"
|
|
769
|
-
];
|
|
770
604
|
/**
|
|
771
605
|
* The command options parser logic.
|
|
772
606
|
*/
|
|
773
607
|
function OptionsParserLogic(props) {
|
|
774
608
|
const { segments = [], options: _options, name: _name, appSpecificEnvPrefix, isCaseSensitive = false } = props;
|
|
775
|
-
const options = computed(() => computedOptions(Object.entries(_options).map(
|
|
609
|
+
const options = computed(() => computedOptions(Object.entries(_options).map(([name, option]) => ({
|
|
776
610
|
...option,
|
|
777
611
|
name
|
|
778
|
-
})
|
|
779
|
-
"param0",
|
|
780
|
-
"",
|
|
781
|
-
"P\"2!\"/\""
|
|
782
|
-
]))));
|
|
612
|
+
}))));
|
|
783
613
|
return [
|
|
784
614
|
createComponent(VarDeclaration, {
|
|
785
615
|
"const": true,
|
|
786
616
|
name: "options",
|
|
787
617
|
get initializer() {
|
|
788
618
|
return code` {
|
|
789
|
-
${segments.length > 0 ? "...useGlobalOptions(), " : ""}${Object.entries(options.value).filter(
|
|
790
|
-
"param0",
|
|
791
|
-
"",
|
|
792
|
-
"P\"2!\"/\""
|
|
793
|
-
])).map(__assignType(([name, option]) => {
|
|
619
|
+
${segments.length > 0 ? "...useGlobalOptions(), " : ""}${Object.entries(options.value).filter(([, option]) => option.env || option.default !== void 0 || (option.type === "string" || option.type === "number") && option.variadic).map(([name, option]) => {
|
|
794
620
|
if (option.type === "string") return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default !== void 0 ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}"${option.default}"` : ""}, `;
|
|
795
621
|
else if (option.type === "number") return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default && Array.isArray(option.default) ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}${option.default}` : ""}, `;
|
|
796
622
|
else if (option.type === "boolean") return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env} ?? ` : ""}${option.default ? "true" : "false"},`;
|
|
797
623
|
return "";
|
|
798
|
-
}
|
|
799
|
-
"param0",
|
|
800
|
-
"",
|
|
801
|
-
"P\"2!\"/\""
|
|
802
|
-
])).join("")}
|
|
624
|
+
}).join("")}
|
|
803
625
|
} as unknown as ${segments.length > 0 ? pascalCase(_name) : "Global"}Options;`;
|
|
804
626
|
}
|
|
805
627
|
}),
|
|
806
628
|
createComponent(Spacing, {}),
|
|
807
|
-
memo(() => code`for (let i = 0; i < args.slice(${segments.filter(
|
|
808
|
-
"segment",
|
|
809
|
-
"",
|
|
810
|
-
"P\"2!\"/\""
|
|
811
|
-
])).length}).length; i++) { `),
|
|
629
|
+
memo(() => code`for (let i = 0; i < args.slice(${segments.filter((segment) => isDynamicPathSegment(segment)).length}).length; i++) { `),
|
|
812
630
|
createIntrinsic("hbr", {}),
|
|
813
631
|
createComponent(VarDeclaration, {
|
|
814
632
|
"const": true,
|
|
@@ -826,81 +644,55 @@ function OptionsParserLogic(props) {
|
|
|
826
644
|
return Object.entries(options.value);
|
|
827
645
|
},
|
|
828
646
|
hardline: true,
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
}), [
|
|
873
|
-
"param0",
|
|
874
|
-
"i",
|
|
875
|
-
"",
|
|
876
|
-
"P\"2!\"2\"\"/#"
|
|
877
|
-
]);
|
|
878
|
-
}
|
|
647
|
+
children: ([name, option], i) => createComponent(Show, {
|
|
648
|
+
when: i === 0,
|
|
649
|
+
get fallback() {
|
|
650
|
+
return createComponent(ElseIfClause, {
|
|
651
|
+
get condition() {
|
|
652
|
+
return [createComponent(OptionsMemberParserCondition, {
|
|
653
|
+
name,
|
|
654
|
+
get alias() {
|
|
655
|
+
return option.alias;
|
|
656
|
+
},
|
|
657
|
+
isCaseSensitive
|
|
658
|
+
})];
|
|
659
|
+
},
|
|
660
|
+
get children() {
|
|
661
|
+
return createComponent(OptionsMemberParserLogic, {
|
|
662
|
+
name,
|
|
663
|
+
option,
|
|
664
|
+
isCaseSensitive
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
get children() {
|
|
670
|
+
return createComponent(IfStatement, {
|
|
671
|
+
get condition() {
|
|
672
|
+
return createComponent(OptionsMemberParserCondition, {
|
|
673
|
+
name,
|
|
674
|
+
get alias() {
|
|
675
|
+
return option.alias;
|
|
676
|
+
},
|
|
677
|
+
isCaseSensitive
|
|
678
|
+
});
|
|
679
|
+
},
|
|
680
|
+
get children() {
|
|
681
|
+
return createComponent(OptionsMemberParserLogic, {
|
|
682
|
+
name,
|
|
683
|
+
option,
|
|
684
|
+
isCaseSensitive
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
})
|
|
879
690
|
}),
|
|
880
691
|
createIntrinsic("hbr", {}),
|
|
881
692
|
code` } `,
|
|
882
693
|
createIntrinsic("hbr", {})
|
|
883
694
|
];
|
|
884
695
|
}
|
|
885
|
-
OptionsParserLogic.__type = [
|
|
886
|
-
() => __ΩOptionsParserLogicProps,
|
|
887
|
-
"props",
|
|
888
|
-
"OptionsParserLogic",
|
|
889
|
-
"The command options parser logic.",
|
|
890
|
-
"Pn!2\"\"/#?$"
|
|
891
|
-
];
|
|
892
|
-
const __ΩCommandParserLogicProps = [
|
|
893
|
-
"CommandTree",
|
|
894
|
-
"command",
|
|
895
|
-
"The command to generate the parser logic for.",
|
|
896
|
-
"appSpecificEnvPrefix",
|
|
897
|
-
"The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",
|
|
898
|
-
"isCaseSensitive",
|
|
899
|
-
true,
|
|
900
|
-
"Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
|
|
901
|
-
"CommandParserLogicProps",
|
|
902
|
-
"P\"w!4\"?#&4$?%)4&8>'?(Mw)y"
|
|
903
|
-
];
|
|
904
696
|
/**
|
|
905
697
|
* The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.
|
|
906
698
|
*/
|
|
@@ -934,14 +726,7 @@ function CommandParserLogic(props) {
|
|
|
934
726
|
createComponent(Spacing, {})
|
|
935
727
|
];
|
|
936
728
|
}
|
|
937
|
-
CommandParserLogic.__type = [
|
|
938
|
-
() => __ΩCommandParserLogicProps,
|
|
939
|
-
"props",
|
|
940
|
-
"CommandParserLogic",
|
|
941
|
-
"The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.",
|
|
942
|
-
"Pn!2\"\"/#?$"
|
|
943
|
-
];
|
|
944
729
|
|
|
945
730
|
//#endregion
|
|
946
|
-
export { ArgumentsParserLogic, CommandParserLogic, DynamicSegmentsParserLogic, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserLogic, OptionsParserLogic
|
|
731
|
+
export { ArgumentsParserLogic, CommandParserLogic, DynamicSegmentsParserLogic, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserLogic, OptionsParserLogic };
|
|
947
732
|
//# sourceMappingURL=options-parser-logic.mjs.map
|