@shell-shock/preset-cli 0.9.20 → 0.9.22
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/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/components/banner-builtin.cjs +93 -5
- package/dist/components/banner-builtin.mjs +90 -5
- package/dist/components/banner-builtin.mjs.map +1 -1
- package/dist/components/command-entry.cjs +359 -56
- package/dist/components/command-entry.mjs +356 -56
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +60 -4
- package/dist/components/command-router.mjs +57 -4
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/index.cjs +15 -1
- package/dist/components/index.mjs +7 -1
- package/dist/components/upgrade-builtin.cjs +135 -14
- package/dist/components/upgrade-builtin.mjs +132 -14
- package/dist/components/upgrade-builtin.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +116 -1
- package/dist/components/virtual-command-entry.mjs +113 -1
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-global-options.cjs +39 -1
- package/dist/helpers/get-global-options.mjs +38 -1
- package/dist/helpers/get-global-options.mjs.map +1 -1
- package/dist/index.cjs +178 -1
- package/dist/index.mjs +169 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +21 -21
|
@@ -1,18 +1,167 @@
|
|
|
1
|
-
import{VirtualCommandEntry
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
|
|
2
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
|
|
4
|
+
import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
|
|
5
|
+
import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
+
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
9
|
+
import { CommandParameterKinds } from "@shell-shock/core";
|
|
10
|
+
import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
|
|
11
|
+
import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
|
|
12
|
+
import { findFilePath, relativePath } from "@stryke/path/find";
|
|
13
|
+
import { joinPaths } from "@stryke/path/join";
|
|
14
|
+
import { replaceExtension } from "@stryke/path/replace";
|
|
15
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
16
|
+
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
17
|
+
import defu from "defu";
|
|
18
|
+
|
|
19
|
+
//#region src/components/command-entry.tsx
|
|
20
|
+
/**
|
|
21
|
+
* The command entry point for the Shell Shock project.
|
|
22
|
+
*/
|
|
23
|
+
function CommandEntry(props) {
|
|
24
|
+
const { command, imports, builtinImports, ...rest } = props;
|
|
25
|
+
const context = usePowerlines();
|
|
26
|
+
const filePath = computed(() => joinPaths(command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
|
|
27
|
+
const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
|
|
28
|
+
const typeDefinition = computed(() => ({
|
|
29
|
+
...command.entry,
|
|
30
|
+
output: command.id
|
|
31
|
+
}));
|
|
32
|
+
return [createComponent(EntryFile, mergeProps(rest, {
|
|
33
|
+
get path() {
|
|
34
|
+
return filePath.value;
|
|
35
|
+
},
|
|
36
|
+
get typeDefinition() {
|
|
37
|
+
return typeDefinition.value;
|
|
38
|
+
},
|
|
39
|
+
get imports() {
|
|
40
|
+
return defu(imports ?? {}, { [commandSourcePath.value.startsWith(".") ? commandSourcePath.value : `./${commandSourcePath.value}`]: `handle${pascalCase(command.name)}` });
|
|
41
|
+
},
|
|
42
|
+
get builtinImports() {
|
|
43
|
+
return defu(builtinImports ?? {}, {
|
|
44
|
+
env: [
|
|
45
|
+
"env",
|
|
46
|
+
"isDevelopment",
|
|
47
|
+
"isDebug",
|
|
48
|
+
"paths"
|
|
49
|
+
],
|
|
50
|
+
console: [
|
|
51
|
+
"debug",
|
|
52
|
+
"info",
|
|
53
|
+
"help",
|
|
54
|
+
"warn",
|
|
55
|
+
"error",
|
|
56
|
+
"table",
|
|
57
|
+
"italic",
|
|
58
|
+
"cursor",
|
|
59
|
+
"stripAnsi",
|
|
60
|
+
"writeLine",
|
|
61
|
+
"splitText",
|
|
62
|
+
"textColors",
|
|
63
|
+
"createSpinner"
|
|
64
|
+
],
|
|
65
|
+
utils: [
|
|
66
|
+
"sleep",
|
|
67
|
+
"isMinimal",
|
|
68
|
+
"isInteractive",
|
|
69
|
+
"isUnicodeSupported"
|
|
70
|
+
],
|
|
71
|
+
state: [
|
|
72
|
+
{
|
|
73
|
+
name: "GlobalOptions",
|
|
74
|
+
type: true
|
|
75
|
+
},
|
|
76
|
+
"useGlobal",
|
|
77
|
+
"useGlobalOptions",
|
|
78
|
+
"withCommand",
|
|
79
|
+
"useArgs",
|
|
80
|
+
"hasFlag",
|
|
81
|
+
"isHelp"
|
|
82
|
+
],
|
|
83
|
+
prompts: [
|
|
84
|
+
"text",
|
|
85
|
+
"numeric",
|
|
86
|
+
"toggle",
|
|
87
|
+
"select",
|
|
88
|
+
"confirm",
|
|
89
|
+
"waitForKeyPress",
|
|
90
|
+
"isCancel"
|
|
91
|
+
],
|
|
92
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
93
|
+
[joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"],
|
|
94
|
+
upgrade: ["executeUpgrade"]
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
get children() {
|
|
98
|
+
return [createComponent(Spacing, {}), createComponent(CommandHandlerDeclaration, {
|
|
99
|
+
command,
|
|
100
|
+
banner: code`await showBanner();
|
|
101
|
+
await executeUpgrade(); `,
|
|
102
|
+
get children() {
|
|
103
|
+
return [createComponent(IfStatement, {
|
|
104
|
+
condition: code`!isInteractive`,
|
|
105
|
+
get children() {
|
|
106
|
+
return createComponent(CommandValidationLogic, { command });
|
|
107
|
+
}
|
|
108
|
+
}), createComponent(Show, {
|
|
109
|
+
get when() {
|
|
110
|
+
return Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 || Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0;
|
|
111
|
+
},
|
|
112
|
+
get children() {
|
|
113
|
+
return createComponent(ElseIfClause, {
|
|
114
|
+
get condition() {
|
|
115
|
+
return code`!isHelp() && (${Object.values(command.options ?? {}).filter((option) => !option.optional).map((option) => (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic ? `(!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} || options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0)` : `options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} === undefined`).join(" || ")}${Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 && Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => !arg.optional).map((arg) => (arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? `(!${camelCase(arg.name)} || ${camelCase(arg.name)}.length === 0)` : `${camelCase(arg.name)} === undefined`).join(" || ")}) `;
|
|
116
|
+
},
|
|
117
|
+
get children() {
|
|
118
|
+
return [
|
|
119
|
+
code`writeLine(""); `,
|
|
120
|
+
createComponent(Spacing, {}),
|
|
121
|
+
createComponent(For, {
|
|
122
|
+
get each() {
|
|
123
|
+
return Object.values(command.options ?? {});
|
|
124
|
+
},
|
|
125
|
+
doubleHardline: true,
|
|
126
|
+
children: (option) => [createComponent(Show, {
|
|
127
|
+
get when() {
|
|
128
|
+
return !option.optional;
|
|
129
|
+
},
|
|
130
|
+
get children() {
|
|
131
|
+
return [createComponent(IfStatement, {
|
|
132
|
+
get condition() {
|
|
133
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
134
|
+
},
|
|
135
|
+
get children() {
|
|
136
|
+
return createComponent(Show, {
|
|
137
|
+
get when() {
|
|
138
|
+
return option.kind === CommandParameterKinds.boolean || !option.choices || option.choices.length === 0;
|
|
139
|
+
},
|
|
140
|
+
get fallback() {
|
|
141
|
+
return code`const value = await select({
|
|
142
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`, ${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
143
|
+
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${formatShortDescription(option.description)}\`` : ""} }`).join(", ")} ]
|
|
5
144
|
});
|
|
6
145
|
if (isCancel(value)) {
|
|
7
146
|
return;
|
|
8
147
|
}
|
|
9
148
|
|
|
10
|
-
options${
|
|
11
|
-
|
|
149
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
150
|
+
`;
|
|
151
|
+
},
|
|
152
|
+
get children() {
|
|
153
|
+
return createComponent(Switch, { get children() {
|
|
154
|
+
return [
|
|
155
|
+
createComponent(Match, {
|
|
156
|
+
get when() {
|
|
157
|
+
return option.kind === CommandParameterKinds.string;
|
|
158
|
+
},
|
|
159
|
+
get children() {
|
|
160
|
+
return code`
|
|
12
161
|
const value = await text({
|
|
13
|
-
message: \`Please provide a value for the \${italic("${
|
|
14
|
-
${
|
|
15
|
-
|
|
162
|
+
message: \`Please provide a value for the \${italic("${option.name}")} option\`,
|
|
163
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
164
|
+
` : ""}validate(val) {
|
|
16
165
|
if (!val || val.trim() === "") {
|
|
17
166
|
return "A value must be provided for this option";
|
|
18
167
|
}
|
|
@@ -24,44 +173,78 @@ import{VirtualCommandEntry as e}from"./virtual-command-entry.mjs";import{createC
|
|
|
24
173
|
return;
|
|
25
174
|
}
|
|
26
175
|
|
|
27
|
-
options${
|
|
28
|
-
|
|
176
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
createComponent(Match, {
|
|
181
|
+
get when() {
|
|
182
|
+
return option.kind === CommandParameterKinds.number;
|
|
183
|
+
},
|
|
184
|
+
get children() {
|
|
185
|
+
return code`
|
|
29
186
|
const value = await numeric({
|
|
30
|
-
message: \`Please provide a numeric value for the \${italic("${
|
|
31
|
-
${
|
|
32
|
-
|
|
187
|
+
message: \`Please provide a numeric value for the \${italic("${option.name}")} option\`,
|
|
188
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
189
|
+
` : ""}
|
|
33
190
|
});
|
|
34
191
|
if (isCancel(value)) {
|
|
35
192
|
return;
|
|
36
193
|
}
|
|
37
194
|
|
|
38
|
-
options${
|
|
39
|
-
|
|
195
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
createComponent(Match, {
|
|
200
|
+
get when() {
|
|
201
|
+
return option.kind === CommandParameterKinds.boolean;
|
|
202
|
+
},
|
|
203
|
+
get children() {
|
|
204
|
+
return code`
|
|
40
205
|
const value = await toggle({
|
|
41
|
-
message: \`Please select a value for the \${italic("${
|
|
42
|
-
${
|
|
43
|
-
|
|
206
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`,
|
|
207
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
208
|
+
` : ""}
|
|
44
209
|
});
|
|
45
210
|
if (isCancel(value)) {
|
|
46
211
|
return;
|
|
47
212
|
}
|
|
48
213
|
|
|
49
|
-
options${
|
|
50
|
-
|
|
214
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
];
|
|
219
|
+
} });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}), createComponent(Show, {
|
|
224
|
+
get when() {
|
|
225
|
+
return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic;
|
|
226
|
+
},
|
|
227
|
+
get children() {
|
|
228
|
+
return createComponent(ElseIfClause, {
|
|
229
|
+
get condition() {
|
|
230
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
|
|
231
|
+
},
|
|
232
|
+
get children() {
|
|
233
|
+
return code`
|
|
51
234
|
const value = await text({
|
|
52
|
-
message: \`Please provide one or more${
|
|
53
|
-
${
|
|
54
|
-
|
|
235
|
+
message: \`Please provide one or more${option.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
236
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
237
|
+
` : ""}validate(val) {
|
|
55
238
|
if (!val || val.trim() === "") {
|
|
56
239
|
return "A value must be provided for this option";
|
|
57
240
|
}
|
|
58
241
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
59
242
|
return "At least one value must be provided for this option";
|
|
60
243
|
}
|
|
61
|
-
${
|
|
244
|
+
${option.kind === CommandParameterKinds.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
62
245
|
if (invalidIndex !== -1) {
|
|
63
246
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
64
|
-
}
|
|
247
|
+
} ` : ""}
|
|
65
248
|
return undefined;
|
|
66
249
|
}
|
|
67
250
|
});
|
|
@@ -69,22 +252,61 @@ import{VirtualCommandEntry as e}from"./virtual-command-entry.mjs";import{createC
|
|
|
69
252
|
return;
|
|
70
253
|
}
|
|
71
254
|
|
|
72
|
-
options${
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
255
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.kind === CommandParameterKinds.number ? `.map(Number)` : ""} ;
|
|
256
|
+
`;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
})];
|
|
261
|
+
}
|
|
262
|
+
})]
|
|
263
|
+
}),
|
|
264
|
+
createComponent(Spacing, {}),
|
|
265
|
+
createComponent(For, {
|
|
266
|
+
get each() {
|
|
267
|
+
return command.args;
|
|
268
|
+
},
|
|
269
|
+
doubleHardline: true,
|
|
270
|
+
children: (arg) => [createComponent(Show, {
|
|
271
|
+
get when() {
|
|
272
|
+
return !arg.optional;
|
|
273
|
+
},
|
|
274
|
+
get children() {
|
|
275
|
+
return [createComponent(IfStatement, {
|
|
276
|
+
get condition() {
|
|
277
|
+
return code`!${camelCase(arg.name)}`;
|
|
278
|
+
},
|
|
279
|
+
get children() {
|
|
280
|
+
return createComponent(Show, {
|
|
281
|
+
get when() {
|
|
282
|
+
return arg.kind === CommandParameterKinds.boolean || !arg.choices || arg.choices.length === 0;
|
|
283
|
+
},
|
|
284
|
+
get fallback() {
|
|
285
|
+
return code`const value = await select({
|
|
286
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,${arg.description ? `description: \`${formatDescription(arg.description)}\`,
|
|
287
|
+
` : ""}
|
|
288
|
+
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
77
289
|
});
|
|
78
290
|
if (isCancel(value)) {
|
|
79
291
|
return;
|
|
80
292
|
}
|
|
81
293
|
|
|
82
|
-
${
|
|
83
|
-
|
|
294
|
+
${camelCase(arg.name)} = value;
|
|
295
|
+
`;
|
|
296
|
+
},
|
|
297
|
+
get children() {
|
|
298
|
+
return createComponent(Switch, { get children() {
|
|
299
|
+
return [
|
|
300
|
+
createComponent(Match, {
|
|
301
|
+
get when() {
|
|
302
|
+
return arg.kind === CommandParameterKinds.string;
|
|
303
|
+
},
|
|
304
|
+
get children() {
|
|
305
|
+
return code`
|
|
84
306
|
const value = await text({
|
|
85
|
-
message: \`Please provide a value for the \${italic("${
|
|
86
|
-
${
|
|
87
|
-
|
|
307
|
+
message: \`Please provide a value for the \${italic("${arg.name}")} argument\`,
|
|
308
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
309
|
+
` : ""}validate(val) {
|
|
88
310
|
if (!val || val.trim() === "") {
|
|
89
311
|
return "A value must be provided for this argument";
|
|
90
312
|
}
|
|
@@ -96,44 +318,78 @@ import{VirtualCommandEntry as e}from"./virtual-command-entry.mjs";import{createC
|
|
|
96
318
|
return;
|
|
97
319
|
}
|
|
98
320
|
|
|
99
|
-
${
|
|
100
|
-
|
|
321
|
+
${camelCase(arg.name)} = value;
|
|
322
|
+
`;
|
|
323
|
+
}
|
|
324
|
+
}),
|
|
325
|
+
createComponent(Match, {
|
|
326
|
+
get when() {
|
|
327
|
+
return arg.kind === CommandParameterKinds.number;
|
|
328
|
+
},
|
|
329
|
+
get children() {
|
|
330
|
+
return code`
|
|
101
331
|
const value = await numeric({
|
|
102
|
-
message: \`Please provide a numeric value for the \${italic("${
|
|
103
|
-
${
|
|
104
|
-
|
|
332
|
+
message: \`Please provide a numeric value for the \${italic("${arg.name}")} argument\`,
|
|
333
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
334
|
+
` : ""}
|
|
105
335
|
});
|
|
106
336
|
if (isCancel(value)) {
|
|
107
337
|
return;
|
|
108
338
|
}
|
|
109
339
|
|
|
110
|
-
${
|
|
111
|
-
|
|
340
|
+
${camelCase(arg.name)} = value;
|
|
341
|
+
`;
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
createComponent(Match, {
|
|
345
|
+
get when() {
|
|
346
|
+
return arg.kind === CommandParameterKinds.boolean;
|
|
347
|
+
},
|
|
348
|
+
get children() {
|
|
349
|
+
return code`
|
|
112
350
|
const value = await toggle({
|
|
113
|
-
message: \`Please select a value for the \${italic("${
|
|
114
|
-
${
|
|
115
|
-
|
|
351
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,
|
|
352
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
353
|
+
` : ""}
|
|
116
354
|
});
|
|
117
355
|
if (isCancel(value)) {
|
|
118
356
|
return;
|
|
119
357
|
}
|
|
120
358
|
|
|
121
|
-
${
|
|
122
|
-
|
|
359
|
+
${camelCase(arg.name)} = value;
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
];
|
|
364
|
+
} });
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}), createComponent(Show, {
|
|
369
|
+
get when() {
|
|
370
|
+
return arg.variadic;
|
|
371
|
+
},
|
|
372
|
+
get children() {
|
|
373
|
+
return createComponent(ElseIfClause, {
|
|
374
|
+
get condition() {
|
|
375
|
+
return code`${camelCase(arg.name)}.length === 0`;
|
|
376
|
+
},
|
|
377
|
+
get children() {
|
|
378
|
+
return code`
|
|
123
379
|
const value = await text({
|
|
124
|
-
message: \`Please provide one or more${
|
|
125
|
-
${
|
|
126
|
-
|
|
380
|
+
message: \`Please provide one or more${arg.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
381
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
382
|
+
` : ""}validate(val) {
|
|
127
383
|
if (!val || val.trim() === "") {
|
|
128
384
|
return "A value must be provided for this argument";
|
|
129
385
|
}
|
|
130
386
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
131
387
|
return "At least one value must be provided for this argument";
|
|
132
388
|
}
|
|
133
|
-
${
|
|
389
|
+
${arg.kind === CommandParameterKinds.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
134
390
|
if (invalidIndex !== -1) {
|
|
135
391
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
136
|
-
}
|
|
392
|
+
} ` : ""}
|
|
137
393
|
|
|
138
394
|
return undefined;
|
|
139
395
|
}
|
|
@@ -142,7 +398,51 @@ import{VirtualCommandEntry as e}from"./virtual-command-entry.mjs";import{createC
|
|
|
142
398
|
return;
|
|
143
399
|
}
|
|
144
400
|
|
|
145
|
-
${
|
|
146
|
-
|
|
147
|
-
|
|
401
|
+
${camelCase(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.kind === CommandParameterKinds.number ? `.map(Number)` : arg.kind === CommandParameterKinds.boolean ? `.map(Boolean)` : ""} ;
|
|
402
|
+
`;
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
})];
|
|
407
|
+
}
|
|
408
|
+
})]
|
|
409
|
+
}),
|
|
410
|
+
code`writeLine(""); `,
|
|
411
|
+
createComponent(Spacing, {}),
|
|
412
|
+
createComponent(CommandValidationLogic, { command }),
|
|
413
|
+
createComponent(IfStatement, {
|
|
414
|
+
condition: code`failures.length > 0`,
|
|
415
|
+
get children() {
|
|
416
|
+
return code`error(\`The following validation failures were found while processing the user provided input, and must be corrected before the \${italic("${command.title}")} command can be executed: \\n\\n\${failures.map(failure => " - " + failure).join("\\n")}\`);
|
|
417
|
+
options.help = true; `;
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
})];
|
|
425
|
+
}
|
|
426
|
+
})];
|
|
427
|
+
}
|
|
428
|
+
})), createComponent(For, {
|
|
429
|
+
get each() {
|
|
430
|
+
return Object.values(command.children);
|
|
431
|
+
},
|
|
432
|
+
children: (child) => createComponent(Show, {
|
|
433
|
+
get when() {
|
|
434
|
+
return child.isVirtual;
|
|
435
|
+
},
|
|
436
|
+
get fallback() {
|
|
437
|
+
return createComponent(CommandEntry, { command: child });
|
|
438
|
+
},
|
|
439
|
+
get children() {
|
|
440
|
+
return createComponent(VirtualCommandEntry, { command: child });
|
|
441
|
+
}
|
|
442
|
+
})
|
|
443
|
+
})];
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
//#endregion
|
|
447
|
+
export { CommandEntry };
|
|
148
448
|
//# sourceMappingURL=command-entry.mjs.map
|