@shell-shock/preset-script 0.4.2 → 0.6.0

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.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/dist/components/banner-function-declaration.cjs +1 -1
  3. package/dist/components/banner-function-declaration.cjs.map +1 -1
  4. package/dist/components/banner-function-declaration.mjs +1 -1
  5. package/dist/components/banner-function-declaration.mjs.map +1 -1
  6. package/dist/components/bin-entry.cjs +1 -2
  7. package/dist/components/bin-entry.cjs.map +1 -1
  8. package/dist/components/bin-entry.d.cts.map +1 -1
  9. package/dist/components/bin-entry.d.mts.map +1 -1
  10. package/dist/components/bin-entry.mjs +1 -2
  11. package/dist/components/bin-entry.mjs.map +1 -1
  12. package/dist/components/command-entry.cjs +205 -7
  13. package/dist/components/command-entry.cjs.map +1 -1
  14. package/dist/components/command-entry.d.cts.map +1 -1
  15. package/dist/components/command-entry.d.mts.map +1 -1
  16. package/dist/components/command-entry.mjs +206 -8
  17. package/dist/components/command-entry.mjs.map +1 -1
  18. package/dist/components/command-router.cjs +5 -5
  19. package/dist/components/command-router.cjs.map +1 -1
  20. package/dist/components/command-router.d.cts +1 -1
  21. package/dist/components/command-router.d.cts.map +1 -1
  22. package/dist/components/command-router.d.mts +1 -1
  23. package/dist/components/command-router.d.mts.map +1 -1
  24. package/dist/components/command-router.mjs +5 -5
  25. package/dist/components/command-router.mjs.map +1 -1
  26. package/dist/components/console-builtin.cjs +15 -10
  27. package/dist/components/console-builtin.cjs.map +1 -1
  28. package/dist/components/console-builtin.d.cts.map +1 -1
  29. package/dist/components/console-builtin.d.mts.map +1 -1
  30. package/dist/components/console-builtin.mjs +15 -10
  31. package/dist/components/console-builtin.mjs.map +1 -1
  32. package/dist/components/help.cjs +25 -18
  33. package/dist/components/help.cjs.map +1 -1
  34. package/dist/components/help.d.cts +9 -9
  35. package/dist/components/help.d.cts.map +1 -1
  36. package/dist/components/help.d.mts +9 -9
  37. package/dist/components/help.d.mts.map +1 -1
  38. package/dist/components/help.mjs +26 -19
  39. package/dist/components/help.mjs.map +1 -1
  40. package/dist/components/helpers.cjs +54 -0
  41. package/dist/components/helpers.cjs.map +1 -0
  42. package/dist/components/helpers.d.cts +29 -0
  43. package/dist/components/helpers.d.cts.map +1 -0
  44. package/dist/components/helpers.d.mts +29 -0
  45. package/dist/components/helpers.d.mts.map +1 -0
  46. package/dist/components/helpers.mjs +50 -0
  47. package/dist/components/helpers.mjs.map +1 -0
  48. package/dist/components/index.cjs +1 -0
  49. package/dist/components/index.d.cts +2 -2
  50. package/dist/components/index.d.mts +2 -2
  51. package/dist/components/index.mjs +2 -2
  52. package/dist/components/utils-builtin.cjs +160 -6
  53. package/dist/components/utils-builtin.cjs.map +1 -1
  54. package/dist/components/utils-builtin.d.cts +9 -8
  55. package/dist/components/utils-builtin.d.cts.map +1 -1
  56. package/dist/components/utils-builtin.d.mts +9 -8
  57. package/dist/components/utils-builtin.d.mts.map +1 -1
  58. package/dist/components/utils-builtin.mjs +161 -8
  59. package/dist/components/utils-builtin.mjs.map +1 -1
  60. package/dist/components/virtual-command-entry.cjs +10 -7
  61. package/dist/components/virtual-command-entry.cjs.map +1 -1
  62. package/dist/components/virtual-command-entry.mjs +10 -7
  63. package/dist/components/virtual-command-entry.mjs.map +1 -1
  64. package/dist/helpers/ansi-utils.cjs +4 -4
  65. package/dist/helpers/ansi-utils.cjs.map +1 -1
  66. package/dist/helpers/ansi-utils.mjs +4 -4
  67. package/dist/helpers/ansi-utils.mjs.map +1 -1
  68. package/dist/index.cjs +1 -1
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.mjs +1 -1
  71. package/dist/index.mjs.map +1 -1
  72. package/package.json +23 -9
@@ -1,6 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
3
3
  const require_components_help = require('./help.cjs');
4
+ const require_components_helpers = require('./helpers.cjs');
4
5
  const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
5
6
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
6
7
  let __alloy_js_core = require("@alloy-js/core");
@@ -13,16 +14,36 @@ let __stryke_path_replace = require("@stryke/path/replace");
13
14
  let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
14
15
  let defu = require("defu");
15
16
  defu = require_rolldown_runtime.__toESM(defu);
17
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
18
+ let __powerlines_plugin_alloy_core_components_single_line_comment = require("@powerlines/plugin-alloy/core/components/single-line-comment");
16
19
  let __shell_shock_core_components_options_parser_logic = require("@shell-shock/core/components/options-parser-logic");
17
20
  let __stryke_path_find = require("@stryke/path/find");
18
21
  let __stryke_path_join = require("@stryke/path/join");
19
22
  let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
20
23
  let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
24
+ let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
21
25
 
22
26
  //#region src/components/command-entry.tsx
23
27
  function CommandInvocation(props) {
24
28
  const { command } = props;
25
- return [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`return Promise.resolve(handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}(options${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).map((segment) => (0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))).join(", ")}` : ""}${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).length > 0 ? `, ${command.path.segments.filter((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).map((segment) => (0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))).join(", ")}` : ""}${command.params.length > 0 ? `, ${command.params.map((param) => (0, __stryke_string_format_camel_case.camelCase)(param.name)).join(", ")}` : ""}));`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
29
+ return [
30
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
31
+ name: "__context",
32
+ get initializer() {
33
+ return __alloy_js_core.code`{ path: \`${command.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment) ? `\${${(0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))}}` : segment).join("/")}\`, segments: [${command.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment) ? (0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment)) : `"${segment}"`).join(", ")}] }`;
34
+ }
35
+ }),
36
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
37
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
38
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
39
+
40
+ internal_commandContext.call(__context, () => {
41
+ return Promise.resolve(Reflect.apply(handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}, __context, [options${command.arguments.length > 0 ? `, ${command.arguments.map((argument) => (0, __stryke_string_format_camel_case.camelCase)(argument.name)).join(", ")}` : ""}]));
42
+ });
43
+
44
+ `),
45
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
46
+ ];
26
47
  }
27
48
  /**
28
49
  * A component that generates the `handler` function declaration for a command.
@@ -36,7 +57,7 @@ function CommandHandlerDeclaration(props) {
36
57
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
37
58
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
38
59
  get heading() {
39
- return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment) ? `[${(0, __stryke_string_format_constant_case.constantCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))}]` : segment).join(" ")}) command.`;
60
+ return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment) ? `[${(0, __stryke_string_format_constant_case.constantCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))}]` : segment).join(" ")}) command.`;
40
61
  },
41
62
  get children() {
42
63
  return [
@@ -74,8 +95,25 @@ function CommandHandlerDeclaration(props) {
74
95
  return context.config.isCaseSensitive;
75
96
  }
76
97
  }),
98
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
99
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
77
100
  __alloy_js_core.code`writeLine("");
78
- banner();`,
101
+ banner(); `,
102
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
103
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
104
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
105
+ get condition() {
106
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_helpers.IsDebug, {});
107
+ },
108
+ get children() {
109
+ return __alloy_js_core.code`
110
+ writeLine("");
111
+ writeLine(colors.text.body.tertiary("Debug mode is enabled. Additional debug information may be logged to the console."));
112
+
113
+ writeLine("");
114
+ debug(\`Command path: ${command.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment) ? `\${${(0, __stryke_string_format_camel_case.camelCase)((0, __shell_shock_core_plugin_utils_context_helpers.getDynamicPathSegmentName)(segment))}}` : segment).join(" / ")} \\n\\nOptions: \\n${Object.values(command.options).map((option) => ` - ${(0, __stryke_string_format_kebab_case.kebabCase)(option.name)}: \${options.${(0, __stryke_string_format_camel_case.camelCase)(option.name)} === undefined ? "" : JSON.stringify(options.${(0, __stryke_string_format_camel_case.camelCase)(option.name)})}`).join("\\n")}${command.arguments.length > 0 ? ` \\n\\nArguments: \\n${command.arguments.map((argument) => ` - ${(0, __stryke_string_format_kebab_case.kebabCase)(argument.name)}: \${${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} === undefined ? "" : JSON.stringify(${(0, __stryke_string_format_camel_case.camelCase)(argument.name)})}`).join("\\n")}` : ""}\`); `;
115
+ }
116
+ }),
79
117
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
80
118
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
81
119
  children,
@@ -101,7 +139,7 @@ function CommandHandlerDeclaration(props) {
101
139
  function CommandEntry(props) {
102
140
  const { command, imports, builtinImports, ...rest } = props;
103
141
  const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
104
- const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).join("/"), "index.ts"));
142
+ const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isDynamicPathSegment)(segment)).join("/"), "index.ts"));
105
143
  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)));
106
144
  const typeDefinition = (0, __alloy_js_core.computed)(() => ({
107
145
  ...command.entry,
@@ -119,8 +157,14 @@ function CommandEntry(props) {
119
157
  },
120
158
  get builtinImports() {
121
159
  return (0, defu.default)(builtinImports ?? {}, {
122
- env: ["env", "isCI"],
160
+ env: [
161
+ "env",
162
+ "isCI",
163
+ "isDevelopment",
164
+ "isDebug"
165
+ ],
123
166
  console: [
167
+ "debug",
124
168
  "warn",
125
169
  "error",
126
170
  "table",
@@ -133,7 +177,8 @@ function CommandEntry(props) {
133
177
  "getArgs",
134
178
  "hasFlag",
135
179
  "isMinimal",
136
- "isUnicodeSupported"
180
+ "isUnicodeSupported",
181
+ "internal_commandContext"
137
182
  ]
138
183
  });
139
184
  },
@@ -145,7 +190,160 @@ function CommandEntry(props) {
145
190
  (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_core_components_options_parser_logic.OptionsInterfaceDeclaration, { command }),
146
191
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
147
192
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
148
- (0, __alloy_js_core_jsx_runtime.createComponent)(CommandHandlerDeclaration, { command })
193
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_single_line_comment.SingleLineComment, { children: __alloy_js_core.code`Validate required options and arguments` }),
194
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
195
+ (0, __alloy_js_core_jsx_runtime.createComponent)(CommandHandlerDeclaration, {
196
+ command,
197
+ get children() {
198
+ return [
199
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
200
+ name: "failures",
201
+ type: "string[]",
202
+ initializer: __alloy_js_core.code`[];`
203
+ }),
204
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
205
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
206
+ get each() {
207
+ return Object.values(command.options ?? {});
208
+ },
209
+ doubleHardline: true,
210
+ children: (option) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
211
+ get when() {
212
+ return !option.optional;
213
+ },
214
+ get children() {
215
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
216
+ get condition() {
217
+ return __alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}`;
218
+ },
219
+ get children() {
220
+ return __alloy_js_core.code`failures.push("Missing required \\"${option.name}\\" option");`;
221
+ }
222
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
223
+ get when() {
224
+ return (option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) && option.variadic;
225
+ },
226
+ get children() {
227
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
228
+ get condition() {
229
+ return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}.length === 0`;
230
+ },
231
+ get children() {
232
+ return __alloy_js_core.code`failures.push("No values were provided to the required \\"${option.name}\\" array option");`;
233
+ }
234
+ });
235
+ }
236
+ })];
237
+ }
238
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
239
+ get when() {
240
+ return option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number;
241
+ },
242
+ get children() {
243
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
244
+ get when() {
245
+ return option.variadic;
246
+ },
247
+ get fallback() {
248
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
249
+ get condition() {
250
+ return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`})`;
251
+ },
252
+ get children() {
253
+ return __alloy_js_core.code`failures.push("Invalid numeric value provided for the \\"${option.name}\\" option");`;
254
+ }
255
+ });
256
+ },
257
+ get children() {
258
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
259
+ get condition() {
260
+ return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}.some(value => Number.isNaN(value))`;
261
+ },
262
+ get children() {
263
+ return __alloy_js_core.code`failures.push("Invalid numeric value provided in the \\"${option.name}\\" array option");`;
264
+ }
265
+ });
266
+ }
267
+ });
268
+ }
269
+ })]
270
+ }),
271
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
272
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
273
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
274
+ get each() {
275
+ return command.arguments;
276
+ },
277
+ doubleHardline: true,
278
+ children: (argument) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
279
+ get when() {
280
+ return !argument.optional;
281
+ },
282
+ get children() {
283
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
284
+ get condition() {
285
+ return __alloy_js_core.code`!${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}`;
286
+ },
287
+ get children() {
288
+ return __alloy_js_core.code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
289
+ }
290
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
291
+ get when() {
292
+ return (argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) && argument.variadic;
293
+ },
294
+ get children() {
295
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
296
+ get condition() {
297
+ return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}.length === 0`;
298
+ },
299
+ get children() {
300
+ return __alloy_js_core.code`failures.push("No values were provided to the required \\"${argument.name}\\" array positional argument");`;
301
+ }
302
+ });
303
+ }
304
+ })];
305
+ }
306
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
307
+ get when() {
308
+ return argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number;
309
+ },
310
+ get children() {
311
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
312
+ get when() {
313
+ return argument.variadic;
314
+ },
315
+ get fallback() {
316
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
317
+ get condition() {
318
+ return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} && Number.isNaN(${(0, __stryke_string_format_camel_case.camelCase)(argument.name)})`;
319
+ },
320
+ get children() {
321
+ return __alloy_js_core.code`failures.push("Invalid numeric value provided for the \\"${argument.name}\\" positional argument");`;
322
+ }
323
+ });
324
+ },
325
+ get children() {
326
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
327
+ get condition() {
328
+ return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}.some(value => Number.isNaN(value))`;
329
+ },
330
+ get children() {
331
+ return __alloy_js_core.code`failures.push("Invalid numeric value provided in the \\"${argument.name}\\" array positional argument");`;
332
+ }
333
+ });
334
+ }
335
+ });
336
+ }
337
+ })]
338
+ }),
339
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
340
+ condition: __alloy_js_core.code`failures.length > 0`,
341
+ children: __alloy_js_core.code`error(colors.text.message.description.error("The following validation failures were found while processing the user provided input, and must be corrected before the command line process can be executed: \\n\\n") + failures.map(failure => colors.text.body.secondary(" - " + failure)).join("\\n"));
342
+ options.help = true; `
343
+ })
344
+ ];
345
+ }
346
+ })
149
347
  ];
150
348
  }
151
349
  })), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","CommandParserLogic","OptionsInterfaceDeclaration","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandHelp","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","params","param","_$createIntrinsic","CommandHandlerDeclaration","children","context","_$createComponent","heading","title","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandHelp } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment => isDynamicPathSegment(segment))\n .length > 0\n ? `, ${command.path.segments\n .filter(segment => isDynamicPathSegment(segment))\n .map(segment => camelCase(getDynamicPathSegmentName(segment)))\n .join(\", \")}`\n : \"\"\n }${\n command.path.segments.filter(segment => isDynamicPathSegment(segment))\n .length > 0\n ? `, ${command.path.segments\n .filter(segment => isDynamicPathSegment(segment))\n .map(segment => camelCase(getDynamicPathSegmentName(segment)))\n .join(\", \")}`\n : \"\"\n }${\n command.params.length > 0\n ? `, ${command.params.map(param => camelCase(param.name)).join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <CommandParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n <CommandHelp command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\", \"isUnicodeSupported\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB6B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,6CAEK9B,oBAAI,mFAA2C+B,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,sFAAgCA,QAAQ,CAAC,CACnEC,SAAS,IACR,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,sFAAgCA,QAAQ,CAAC,CAChDE,KAAIF,4IAA+CA,QAAQ,CAAC,CAAC,CAC7DG,KAAK,KAAK,KACb,KAEJT,QAAQG,KAAKC,SAASC,QAAOC,sFAAgCA,QAAQ,CAAC,CACnEC,SAAS,IACR,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,sFAAgCA,QAAQ,CAAC,CAChDE,KAAIF,4IAA+CA,QAAQ,CAAC,CAAC,CAC7DG,KAAK,KAAK,KACb,KAEJT,QAAQU,OAAOH,SAAS,IACpB,KAAKP,QAAQU,OAAOF,KAA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qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAG1CjB,gFAA2B,EAAUiB,SAAO,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAG5Ca,2BAAyB,EAAUb,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,mDAE5C7B,qBAAG;EAAA,IAAC4E,OAAI;AAAA,UAAEC,OAAOC,OAAOjD,QAAQc,SAAS;;EAAAA,WACvCoC,2DACE9E,sBAAI;GAAA,IACH+E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,4DAAGxB,cAAY,EAAC7B,SAASkD,OAAK,CAAA;;GAAA,IAAApC,WAAA;AAAA,4DACrCjB,8DAAmB,EAACG,SAASkD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","ElseIfClause","FunctionDeclaration","IfStatement","VarDeclaration","ReflectionKind","SingleLineComment","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","CommandParserLogic","OptionsInterfaceDeclaration","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","kebabCase","pascalCase","defu","BannerFunctionDeclaration","CommandHelp","IsDebug","VirtualCommandEntry","CommandInvocation","props","command","_$createComponent","name","initializer","segments","map","segment","join","_$createIntrinsic","_$memo","arguments","length","argument","CommandHandlerDeclaration","children","context","heading","title","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","Object","values","options","option","CommandEntry","imports","builtinImports","rest","filePath","filter","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","path","env","console","utils","each","doubleHardline","when","optional","includes","kind","string","number","variadic","fallback","child","isVirtual"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { SingleLineComment } from \"@powerlines/plugin-alloy/core/components/single-line-comment\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type {\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption\n} from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandHelp } from \"./help\";\nimport { IsDebug } from \"./helpers\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration\n name=\"__context\"\n initializer={code`{ path: \\`${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\"/\")}\\`, segments: [${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? camelCase(getDynamicPathSegmentName(segment))\n : `\"${segment}\"`\n )\n .join(\", \")}] }`}\n />\n <hbr />\n <hbr />\n {code`\n\n internal_commandContext.call(__context, () => {\n return Promise.resolve(Reflect.apply(handle${pascalCase(\n command.name\n )}, __context, [options${\n command.arguments.length > 0\n ? `, ${command.arguments\n .map(argument => camelCase(argument.name))\n .join(\", \")}`\n : \"\"\n }]));\n });\n\n `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <CommandParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner(); `}\n <hbr />\n <hbr />\n <IfStatement condition={<IsDebug />}>\n {code`\n writeLine(\"\");\n writeLine(colors.text.body.tertiary(\"Debug mode is enabled. Additional debug information may be logged to the console.\"));\n\n writeLine(\"\");\n debug(\\`Command path: ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\" / \")} \\\\n\\\\nOptions: \\\\n${Object.values(command.options)\n .map(\n option =>\n ` - ${kebabCase(option.name)}: \\${options.${camelCase(\n option.name\n )} === undefined ? \"\" : JSON.stringify(options.${camelCase(\n option.name\n )})}`\n )\n .join(\"\\\\n\")}${\n command.arguments.length > 0\n ? ` \\\\n\\\\nArguments: \\\\n${command.arguments\n .map(\n argument =>\n ` - ${kebabCase(argument.name)}: \\${${camelCase(\n argument.name\n )} === undefined ? \"\" : JSON.stringify(${camelCase(\n argument.name\n )})}`\n )\n .join(\"\\\\n\")}`\n : \"\"\n }\\`); `}\n </IfStatement>\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n <CommandHelp command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\", \"isDevelopment\", \"isDebug\"],\n console: [\n \"debug\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\n \"getArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <SingleLineComment>{code`Validate required options and arguments`}</SingleLineComment>\n <hbr />\n <CommandHandlerDeclaration command={command}>\n <VarDeclaration\n name=\"failures\"\n type=\"string[]\"\n initializer={code`[];`}\n />\n <hbr />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n {code`failures.push(\"Missing required \\\\\"${option.name}\\\\\" option\");`}\n </IfStatement>\n <Show\n when={\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === ReflectionKind.number}>\n <Show\n when={(option as NumberCommandOption).variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n option.name\n }\\\\\" option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n <hbr />\n <hbr />\n <For each={command.arguments} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show\n when={\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === ReflectionKind.number}>\n <Show\n when={(argument as NumberCommandArgument).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(colors.text.message.description.error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command line process can be executed: \\\\n\\\\n\") + failures.map(failure => colors.text.body.secondary(\" - \" + failure)).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAgBmC,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA;mDAEK5B,sCAAc;GACb+B,MAAI;GAAA,IACJC,cAAW;AAAA,WAAExC,oBAAI,aAAaqC,QAAQI,SACnCC,KAAIC,sFACkBA,QAAQ,GACzB,sIAA0CA,QAAQ,CAAC,CAAA,KACnDA,QACL,CACAC,KAAK,IAAI,CAAA,iBAAkBP,QAAQI,SACnCC,KAAIC,sFACkBA,QAAQ,mIACWA,QAAQ,CAAC,GAC7C,IAAIA,QAAO,GAChB,CACAC,KAAK,KAAK,CAAA;;GAAK,CAAA;mDAAA,OAAA,EAAA,CAAA;mDAAA,OAAA,EAAA,CAAA;8CAInB5C,oBAAI;;;wGAIDqC,QAAQE,KACT,CAAA,uBACCF,QAAQU,UAAUC,SAAS,IACvB,KAAKX,QAAQU,UACVL,KAAIO,8DAAsBA,SAASV,KAAK,CAAC,CACzCK,KAAK,KAAK,KACb,GAAE;;;QAIT;mDAAA,OAAA,EAAA,CAAA;EAAA;;;;;AAcP,SAAgBM,0BACdd,OACA;CACA,MAAM,EAAEC,SAASc,aAAaf;CAE9B,MAAMgB,8EAA8C;AAEpD,QAAA;mDAEKlC,gFAA2B,EAAUmB,SAAO,CAAA;mDAAA,OAAA,EAAA,CAAA;mDAAA,OAAA,EAAA,CAAA;mDAG5C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A;;WAAA,IAAAY,WAAA;AAAA,oEAG/B5C,mCAAW;aAAA,IACVyD,YAAS;AAAA,qBAAEhE,oBAAI,oDAAaiD,SAASV,KAAK,CAAA;;aAAqC,IAAAY,WAAA;AAAA,qBAC9EnD,oBAAI,2DACHiD,SAASV,KAAI;;aACmB,CAAA;;WAAA,CAAA;;SAAA,CAAA,CAAA;QAK3C,CAAA;wDAEFhC,mCAAW;QAACyD,WAAWhE,oBAAI;QAAqBmD,UAC9CnD,oBAAI;;QACiB,CAAA;OAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA,mDAI3BE,qBAAG;EAAA,IAACuF,OAAI;AAAA,UAAExB,OAAOC,OAAO7B,QAAQc,SAAS;;EAAAA,WACvCgD,2DACEhG,sBAAI;GAAA,IACHwF,OAAI;AAAA,WAAEQ,MAAMC;;GAAS,IACrBF,WAAQ;AAAA,4DAAG7B,cAAY,EAAChC,SAAS8D,OAAK,CAAA;;GAAA,IAAAhD,WAAA;AAAA,4DACrCjB,8DAAmB,EAACG,SAAS8D,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAwDgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AA+BC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EAwDC,QAAA,CAAA,EA9DJ,QA8DI;;;;;AAUD,iBAlEA,yBAAA,CAkEqC,KAAA,EAjE5C,8BAiE4C,CAAA,EAjEd,QAiEc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
1
+ {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAkEgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AA2CC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EA8FC,QAAA,CAAA,EApGJ,QAoGI;;;;;AAUD,iBAxGA,yBAAA,CAwGqC,KAAA,EAvG5C,8BAuG4C,CAAA,EAvGd,QAuGc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAwDgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AA+BC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EAwDC,QAAA,CAAA,EA9DJ,QA8DI;;;;;AAUD,iBAlEA,yBAAA,CAkEqC,KAAA,EAjE5C,8BAiE4C,CAAA,EAjEd,QAiEc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
1
+ {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAkEgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AA2CC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EA8FC,QAAA,CAAA,EApGJ,QAoGI;;;;;AAUD,iBAxGA,yBAAA,CAwGqC,KAAA,EAvG5C,8BAuG4C,CAAA,EAvGd,QAuGc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}