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