@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.
@@ -1,18 +1,167 @@
1
- import{VirtualCommandEntry as e}from"./virtual-command-entry.mjs";import{createComponent as t,mergeProps as n}from"@alloy-js/core/jsx-runtime";import{For as r,Match as i,Show as a,Switch as o,code as s,computed as c}from"@alloy-js/core";import{ElseIfClause as l,IfStatement as u}from"@alloy-js/typescript";import{formatDescription as d,formatShortDescription as f,isDynamicPathSegment as p}from"@shell-shock/core/plugin-utils";import{Spacing as m}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as h}from"@powerlines/plugin-alloy/core/contexts/context";import{EntryFile as g}from"@powerlines/plugin-alloy/typescript/components/entry-file";import{CommandParameterKinds as _}from"@shell-shock/core";import{CommandValidationLogic as v}from"@shell-shock/core/components/command-validation-logic";import{CommandHandlerDeclaration as y}from"@shell-shock/preset-script/components/command-entry";import{findFilePath as b,relativePath as x}from"@stryke/path/find";import{joinPaths as S}from"@stryke/path/join";import{replaceExtension as C}from"@stryke/path/replace";import{camelCase as w}from"@stryke/string-format/camel-case";import{pascalCase as T}from"@stryke/string-format/pascal-case";import E from"defu";function D(O){let{command:k,imports:A,builtinImports:j,...M}=O,N=h(),P=c(()=>S(k.segments.filter(e=>!p(e)).join(`/`),`index.ts`)),F=c(()=>C(x(S(N.entryPath,b(P.value)),k.entry.input?.file||k.entry.file))),I=c(()=>({...k.entry,output:k.id}));return[t(g,n(M,{get path(){return P.value},get typeDefinition(){return I.value},get imports(){return E(A??{},{[F.value.startsWith(`.`)?F.value:`./${F.value}`]:`handle${T(k.name)}`})},get builtinImports(){return E(j??{},{env:[`env`,`isDevelopment`,`isDebug`,`paths`],console:[`debug`,`info`,`help`,`warn`,`error`,`table`,`italic`,`cursor`,`stripAnsi`,`writeLine`,`splitText`,`textColors`,`createSpinner`],utils:[`sleep`,`isMinimal`,`isInteractive`,`isUnicodeSupported`],state:[{name:`GlobalOptions`,type:!0},`useGlobal`,`useGlobalOptions`,`withCommand`,`useArgs`,`hasFlag`,`isHelp`],prompts:[`text`,`numeric`,`toggle`,`select`,`confirm`,`waitForKeyPress`,`isCancel`],[S(`help`,...k.segments.filter(e=>!p(e)))]:[`showHelp`],[S(`banner`,...k.segments.filter(e=>!p(e)))]:[`showBanner`],upgrade:[`executeUpgrade`]})},get children(){return[t(m,{}),t(y,{command:k,banner:s`await showBanner();
2
- await executeUpgrade(); `,get children(){return[t(u,{condition:s`!isInteractive`,get children(){return t(v,{command:k})}}),t(a,{get when(){return Object.values(k.options??{}).filter(e=>!e.optional).length>0||Object.values(k.args??{}).filter(e=>!e.optional).length>0},get children(){return t(l,{get condition(){return s`!isHelp() && (${Object.values(k.options??{}).filter(e=>!e.optional).map(e=>(e.kind===_.string||e.kind===_.number)&&e.variadic?`(!options${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} || options${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`}.length === 0)`:`options${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} === undefined`).join(` || `)}${Object.values(k.options??{}).filter(e=>!e.optional).length>0&&Object.values(k.args??{}).filter(e=>!e.optional).length>0?` || `:``}${Object.values(k.args??{}).filter(e=>!e.optional).map(e=>(e.kind===_.string||e.kind===_.number)&&e.variadic?`(!${w(e.name)} || ${w(e.name)}.length === 0)`:`${w(e.name)} === undefined`).join(` || `)}) `},get children(){return[s`writeLine(""); `,t(m,{}),t(r,{get each(){return Object.values(k.options??{})},doubleHardline:!0,children:e=>[t(a,{get when(){return!e.optional},get children(){return[t(u,{get condition(){return s`!options${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`}`},get children(){return t(a,{get when(){return e.kind===_.boolean||!e.choices||e.choices.length===0},get fallback(){return s`const value = await select({
3
- message: \`Please select a value for the \${italic("${e.name}")} option\`, ${e.description?`description: \`${d(e.description)}\`,
4
- `:``}options: [ ${e.choices?.map(t=>`{ value: ${JSON.stringify(t)}, label: "${t}", ${e.description?`description: \`${f(e.description)}\``:``} }`).join(`, `)} ]
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${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} = value;
11
- `},get children(){return t(o,{get children(){return[t(i,{get when(){return e.kind===_.string},get children(){return s`
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("${e.name}")} option\`,
14
- ${e.description?`description: \`${d(e.description)}\`,
15
- `:``}validate(val) {
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${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} = value;
28
- `}}),t(i,{get when(){return e.kind===_.number},get children(){return s`
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("${e.name}")} option\`,
31
- ${e.description?`description: \`${d(e.description)}\`,
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${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} = value;
39
- `}}),t(i,{get when(){return e.kind===_.boolean},get children(){return s`
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("${e.name}")} option\`,
42
- ${e.description?`description: \`${d(e.description)}\`,
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${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} = value;
50
- `}})]}})}})}}),t(a,{get when(){return(e.kind===_.string||e.kind===_.number)&&e.variadic},get children(){return t(l,{get condition(){return s`options${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`}.length === 0`},get children(){return s`
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${e.kind===_.number?` numeric`:``} values for the \${italic("${e.name}")} option (values are separated by a \\",\\" character)\`,
53
- ${e.description?`description: \`${d(e.description)}\`,
54
- `:``}validate(val) {
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
- ${e.kind===_.number?`const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
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${e.name.includes(`?`)?`["${e.name}"]`:`.${w(e.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${e.kind===_.number?`.map(Number)`:``} ;
73
- `}})}})]}})]}),t(m,{}),t(r,{get each(){return k.args},doubleHardline:!0,children:e=>[t(a,{get when(){return!e.optional},get children(){return[t(u,{get condition(){return s`!${w(e.name)}`},get children(){return t(a,{get when(){return e.kind===_.boolean||!e.choices||e.choices.length===0},get fallback(){return s`const value = await select({
74
- message: \`Please select a value for the \${italic("${e.name}")} argument\`,${e.description?`description: \`${d(e.description)}\`,
75
- `:``}
76
- options: [ ${e.choices?.map(t=>`{ value: ${JSON.stringify(t)}, label: "${t}", ${e.description?`description: \`${f(e.description)}\``:``} }`).join(`, `)} ]
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
- ${w(e.name)} = value;
83
- `},get children(){return t(o,{get children(){return[t(i,{get when(){return e.kind===_.string},get children(){return s`
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("${e.name}")} argument\`,
86
- ${e.description?`description: \`${f(e.description)}\`,
87
- `:``}validate(val) {
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
- ${w(e.name)} = value;
100
- `}}),t(i,{get when(){return e.kind===_.number},get children(){return s`
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("${e.name}")} argument\`,
103
- ${e.description?`description: \`${f(e.description)}\`,
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
- ${w(e.name)} = value;
111
- `}}),t(i,{get when(){return e.kind===_.boolean},get children(){return s`
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("${e.name}")} argument\`,
114
- ${e.description?`description: \`${f(e.description)}\`,
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
- ${w(e.name)} = value;
122
- `}})]}})}})}}),t(a,{get when(){return e.variadic},get children(){return t(l,{get condition(){return s`${w(e.name)}.length === 0`},get children(){return s`
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${e.kind===_.number?` numeric`:``} values for the \${italic("${e.name}")} argument (values are separated by a \\",\\" character)\`,
125
- ${e.description?`description: \`${f(e.description)}\`,
126
- `:``}validate(val) {
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
- ${e.kind===_.number?`const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
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
- ${w(e.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${e.kind===_.number?`.map(Number)`:e.kind===_.boolean?`.map(Boolean)`:``} ;
146
- `}})}})]}})]}),s`writeLine(""); `,t(m,{}),t(v,{command:k}),t(u,{condition:s`failures.length > 0`,get children(){return s`error(\`The following validation failures were found while processing the user provided input, and must be corrected before the \${italic("${k.title}")} command can be executed: \\n\\n\${failures.map(failure => " - " + failure).join("\\n")}\`);
147
- options.help = true; `}})]}})}})]}})]}})),t(r,{get each(){return Object.values(k.children)},children:n=>t(a,{get when(){return n.isVirtual},get fallback(){return t(D,{command:n})},get children(){return t(e,{command:n})}})})]}export{D as CommandEntry};
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