@shell-shock/preset-cli 0.9.22 → 0.9.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/banner-builtin.cjs +0 -1
- package/dist/components/banner-builtin.d.cts +2 -3
- package/dist/components/banner-builtin.d.cts.map +1 -1
- package/dist/components/banner-builtin.d.mts +3 -4
- package/dist/components/banner-builtin.d.mts.map +1 -1
- package/dist/components/banner-builtin.mjs.map +1 -1
- package/dist/components/command-entry.cjs +21 -22
- package/dist/components/command-entry.d.cts +1 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +1 -2
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +21 -22
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +1 -2
- package/dist/components/command-router.d.cts +2 -3
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts +3 -4
- package/dist/components/command-router.d.mts.map +1 -1
- package/dist/components/command-router.mjs +1 -1
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/upgrade-builtin.cjs +2 -3
- package/dist/components/upgrade-builtin.d.cts +2 -3
- package/dist/components/upgrade-builtin.d.cts.map +1 -1
- package/dist/components/upgrade-builtin.d.mts +2 -3
- package/dist/components/upgrade-builtin.d.mts.map +1 -1
- package/dist/components/upgrade-builtin.mjs +2 -2
- package/dist/components/upgrade-builtin.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +3 -3
- package/dist/components/virtual-command-entry.d.cts +1 -2
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +1 -2
- package/dist/components/virtual-command-entry.d.mts.map +1 -1
- package/dist/components/virtual-command-entry.mjs +3 -3
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-global-options.cjs +4 -6
- package/dist/helpers/get-global-options.mjs +4 -5
- package/dist/helpers/get-global-options.mjs.map +1 -1
- package/dist/index.cjs +13 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +12 -6
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts +11 -3
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +12 -4
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +24 -23
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
3
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
4
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
1
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
2
|
import { CommandTree } from "@shell-shock/core";
|
|
4
3
|
import { BannerFunctionBodyDeclarationProps } from "@shell-shock/plugin-banner/components/banner-function-declaration";
|
|
@@ -7,7 +6,7 @@ import { BannerFunctionBodyDeclarationProps } from "@shell-shock/plugin-banner/c
|
|
|
7
6
|
/**
|
|
8
7
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
9
8
|
*/
|
|
10
|
-
declare function BannerFunctionBodyDeclaration(props: Omit<BannerFunctionBodyDeclarationProps, "header" | "description" | "footer">):
|
|
9
|
+
declare function BannerFunctionBodyDeclaration(props: Omit<BannerFunctionBodyDeclarationProps, "header" | "description" | "footer">): import("@alloy-js/core").Children;
|
|
11
10
|
type BannerBuiltinProps = Omit<BuiltinFileProps, "id" | "description"> & {
|
|
12
11
|
/**
|
|
13
12
|
* The command to generate the `banner` function declaration for.
|
|
@@ -17,7 +16,7 @@ type BannerBuiltinProps = Omit<BuiltinFileProps, "id" | "description"> & {
|
|
|
17
16
|
/**
|
|
18
17
|
* A built-in banner module for Shell Shock.
|
|
19
18
|
*/
|
|
20
|
-
declare function BannerBuiltin(props: BannerBuiltinProps):
|
|
19
|
+
declare function BannerBuiltin(props: BannerBuiltinProps): import("@alloy-js/core").Children;
|
|
21
20
|
//#endregion
|
|
22
21
|
export { BannerBuiltin, BannerBuiltinProps, BannerFunctionBodyDeclaration };
|
|
23
22
|
//# sourceMappingURL=banner-builtin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.d.cts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"banner-builtin.d.cts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":";;;;;;;AAqCA;iBAAgB,6BAAA,CACd,KAAA,EAAO,IAAI,CACT,kCAAA,kEAED,QAAA;AAAA,KAqFS,kBAAA,GAAqB,IAAA,CAC/B,gBAAA;EAzFW;;;EA+FX,OAAA,EAAS,WAAA;AAAA;;AA5FR;AAqFH;iBAagB,aAAA,CAAc,KAAA,EAAO,kBAAkB,4BAAA,QAAA"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
1
|
import { BannerFunctionBodyDeclarationProps } from "@shell-shock/plugin-banner/components/banner-function-declaration";
|
|
3
|
-
import { CommandTree } from "@shell-shock/core";
|
|
4
2
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
|
+
import { CommandTree } from "@shell-shock/core";
|
|
5
4
|
|
|
6
5
|
//#region src/components/banner-builtin.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
9
8
|
*/
|
|
10
|
-
declare function BannerFunctionBodyDeclaration(props: Omit<BannerFunctionBodyDeclarationProps, "header" | "description" | "footer">):
|
|
9
|
+
declare function BannerFunctionBodyDeclaration(props: Omit<BannerFunctionBodyDeclarationProps, "header" | "description" | "footer">): import("@alloy-js/core").Children;
|
|
11
10
|
type BannerBuiltinProps = Omit<BuiltinFileProps, "id" | "description"> & {
|
|
12
11
|
/**
|
|
13
12
|
* The command to generate the `banner` function declaration for.
|
|
@@ -17,7 +16,7 @@ type BannerBuiltinProps = Omit<BuiltinFileProps, "id" | "description"> & {
|
|
|
17
16
|
/**
|
|
18
17
|
* A built-in banner module for Shell Shock.
|
|
19
18
|
*/
|
|
20
|
-
declare function BannerBuiltin(props: BannerBuiltinProps):
|
|
19
|
+
declare function BannerBuiltin(props: BannerBuiltinProps): import("@alloy-js/core").Children;
|
|
21
20
|
//#endregion
|
|
22
21
|
export { BannerBuiltin, BannerBuiltinProps, BannerFunctionBodyDeclaration };
|
|
23
22
|
//# sourceMappingURL=banner-builtin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.d.mts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"banner-builtin.d.mts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.mjs","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"banner-builtin.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -5,14 +5,13 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
5
5
|
let _alloy_js_core = require("@alloy-js/core");
|
|
6
6
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
7
7
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
8
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
8
9
|
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
9
10
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
10
11
|
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
12
|
let _shell_shock_core_components_command_validation_logic = require("@shell-shock/core/components/command-validation-logic");
|
|
13
13
|
let _shell_shock_preset_script_components_command_entry = require("@shell-shock/preset-script/components/command-entry");
|
|
14
14
|
let _stryke_path_find = require("@stryke/path/find");
|
|
15
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
16
15
|
let _stryke_path_replace = require("@stryke/path/replace");
|
|
17
16
|
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
18
17
|
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
@@ -110,12 +109,12 @@ function CommandEntry(props) {
|
|
|
110
109
|
}
|
|
111
110
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
112
111
|
get when() {
|
|
113
|
-
return Object.values(command.options ?? {}).filter((option) =>
|
|
112
|
+
return Object.values(command.options ?? {}).filter((option) => option.required).length > 0 || Object.values(command.args ?? {}).filter((arg) => arg.required).length > 0;
|
|
114
113
|
},
|
|
115
114
|
get children() {
|
|
116
115
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
117
116
|
get condition() {
|
|
118
|
-
return _alloy_js_core.code`!isHelp() && (${Object.values(command.options ?? {}).filter((option) =>
|
|
117
|
+
return _alloy_js_core.code`!isHelp() && (${Object.values(command.options ?? {}).filter((option) => option.required).map((option) => (option.type === "string" || option.type === "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.required).length > 0 && Object.values(command.args ?? {}).filter((arg) => arg.required).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => arg.required).map((arg) => (arg.type === "string" || arg.type === "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
118
|
},
|
|
120
119
|
get children() {
|
|
121
120
|
return [
|
|
@@ -128,7 +127,7 @@ function CommandEntry(props) {
|
|
|
128
127
|
doubleHardline: true,
|
|
129
128
|
children: (option) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
130
129
|
get when() {
|
|
131
|
-
return
|
|
130
|
+
return option.required;
|
|
132
131
|
},
|
|
133
132
|
get children() {
|
|
134
133
|
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
@@ -138,7 +137,7 @@ function CommandEntry(props) {
|
|
|
138
137
|
get children() {
|
|
139
138
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
140
139
|
get when() {
|
|
141
|
-
return option.
|
|
140
|
+
return option.type === "boolean" || !option.choices || option.choices.length === 0;
|
|
142
141
|
},
|
|
143
142
|
get fallback() {
|
|
144
143
|
return _alloy_js_core.code`const value = await select({
|
|
@@ -157,7 +156,7 @@ function CommandEntry(props) {
|
|
|
157
156
|
return [
|
|
158
157
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
|
|
159
158
|
get when() {
|
|
160
|
-
return option.
|
|
159
|
+
return option.type === "string";
|
|
161
160
|
},
|
|
162
161
|
get children() {
|
|
163
162
|
return _alloy_js_core.code`
|
|
@@ -182,7 +181,7 @@ function CommandEntry(props) {
|
|
|
182
181
|
}),
|
|
183
182
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
|
|
184
183
|
get when() {
|
|
185
|
-
return option.
|
|
184
|
+
return option.type === "number";
|
|
186
185
|
},
|
|
187
186
|
get children() {
|
|
188
187
|
return _alloy_js_core.code`
|
|
@@ -201,7 +200,7 @@ function CommandEntry(props) {
|
|
|
201
200
|
}),
|
|
202
201
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
|
|
203
202
|
get when() {
|
|
204
|
-
return option.
|
|
203
|
+
return option.type === "boolean";
|
|
205
204
|
},
|
|
206
205
|
get children() {
|
|
207
206
|
return _alloy_js_core.code`
|
|
@@ -225,7 +224,7 @@ function CommandEntry(props) {
|
|
|
225
224
|
}
|
|
226
225
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
227
226
|
get when() {
|
|
228
|
-
return (option.
|
|
227
|
+
return (option.type === "string" || option.type === "number") && option.variadic;
|
|
229
228
|
},
|
|
230
229
|
get children() {
|
|
231
230
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
@@ -235,7 +234,7 @@ function CommandEntry(props) {
|
|
|
235
234
|
get children() {
|
|
236
235
|
return _alloy_js_core.code`
|
|
237
236
|
const value = await text({
|
|
238
|
-
message: \`Please provide one or more${option.
|
|
237
|
+
message: \`Please provide one or more${option.type === "number" ? " numeric" : ""} values for the \${italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
239
238
|
${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
240
239
|
` : ""}validate(val) {
|
|
241
240
|
if (!val || val.trim() === "") {
|
|
@@ -244,7 +243,7 @@ function CommandEntry(props) {
|
|
|
244
243
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
245
244
|
return "At least one value must be provided for this option";
|
|
246
245
|
}
|
|
247
|
-
${option.
|
|
246
|
+
${option.type === "number" ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
248
247
|
if (invalidIndex !== -1) {
|
|
249
248
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
250
249
|
} ` : ""}
|
|
@@ -255,7 +254,7 @@ function CommandEntry(props) {
|
|
|
255
254
|
return;
|
|
256
255
|
}
|
|
257
256
|
|
|
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.
|
|
257
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.type === "number" ? `.map(Number)` : ""} ;
|
|
259
258
|
`;
|
|
260
259
|
}
|
|
261
260
|
});
|
|
@@ -272,7 +271,7 @@ function CommandEntry(props) {
|
|
|
272
271
|
doubleHardline: true,
|
|
273
272
|
children: (arg) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
274
273
|
get when() {
|
|
275
|
-
return
|
|
274
|
+
return arg.required;
|
|
276
275
|
},
|
|
277
276
|
get children() {
|
|
278
277
|
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
@@ -282,7 +281,7 @@ function CommandEntry(props) {
|
|
|
282
281
|
get children() {
|
|
283
282
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
284
283
|
get when() {
|
|
285
|
-
return arg.
|
|
284
|
+
return arg.type === "boolean" || !arg.choices || arg.choices.length === 0;
|
|
286
285
|
},
|
|
287
286
|
get fallback() {
|
|
288
287
|
return _alloy_js_core.code`const value = await select({
|
|
@@ -302,7 +301,7 @@ function CommandEntry(props) {
|
|
|
302
301
|
return [
|
|
303
302
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
|
|
304
303
|
get when() {
|
|
305
|
-
return arg.
|
|
304
|
+
return arg.type === "string";
|
|
306
305
|
},
|
|
307
306
|
get children() {
|
|
308
307
|
return _alloy_js_core.code`
|
|
@@ -327,7 +326,7 @@ function CommandEntry(props) {
|
|
|
327
326
|
}),
|
|
328
327
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
|
|
329
328
|
get when() {
|
|
330
|
-
return arg.
|
|
329
|
+
return arg.type === "number";
|
|
331
330
|
},
|
|
332
331
|
get children() {
|
|
333
332
|
return _alloy_js_core.code`
|
|
@@ -346,7 +345,7 @@ function CommandEntry(props) {
|
|
|
346
345
|
}),
|
|
347
346
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Match, {
|
|
348
347
|
get when() {
|
|
349
|
-
return arg.
|
|
348
|
+
return arg.type === "boolean";
|
|
350
349
|
},
|
|
351
350
|
get children() {
|
|
352
351
|
return _alloy_js_core.code`
|
|
@@ -380,7 +379,7 @@ function CommandEntry(props) {
|
|
|
380
379
|
get children() {
|
|
381
380
|
return _alloy_js_core.code`
|
|
382
381
|
const value = await text({
|
|
383
|
-
message: \`Please provide one or more${arg.
|
|
382
|
+
message: \`Please provide one or more${arg.type === "number" ? " numeric" : ""} values for the \${italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
384
383
|
${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
385
384
|
` : ""}validate(val) {
|
|
386
385
|
if (!val || val.trim() === "") {
|
|
@@ -389,7 +388,7 @@ function CommandEntry(props) {
|
|
|
389
388
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
390
389
|
return "At least one value must be provided for this argument";
|
|
391
390
|
}
|
|
392
|
-
${arg.
|
|
391
|
+
${arg.type === "number" ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
393
392
|
if (invalidIndex !== -1) {
|
|
394
393
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
395
394
|
} ` : ""}
|
|
@@ -401,7 +400,7 @@ function CommandEntry(props) {
|
|
|
401
400
|
return;
|
|
402
401
|
}
|
|
403
402
|
|
|
404
|
-
${(0, _stryke_string_format_camel_case.camelCase)(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.
|
|
403
|
+
${(0, _stryke_string_format_camel_case.camelCase)(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.type === "number" ? `.map(Number)` : arg.type === "boolean" ? `.map(Boolean)` : ""} ;
|
|
405
404
|
`;
|
|
406
405
|
}
|
|
407
406
|
});
|
|
@@ -434,7 +433,7 @@ function CommandEntry(props) {
|
|
|
434
433
|
},
|
|
435
434
|
children: (child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
436
435
|
get when() {
|
|
437
|
-
return child.
|
|
436
|
+
return child.virtual;
|
|
438
437
|
},
|
|
439
438
|
get fallback() {
|
|
440
439
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(CommandEntry, { command: child });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
1
|
import { CommandTree } from "@shell-shock/core";
|
|
3
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
4
3
|
|
|
@@ -9,7 +8,7 @@ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinitio
|
|
|
9
8
|
/**
|
|
10
9
|
* The command entry point for the Shell Shock project.
|
|
11
10
|
*/
|
|
12
|
-
declare function CommandEntry(props: CommandEntryProps):
|
|
11
|
+
declare function CommandEntry(props: CommandEntryProps): import("@alloy-js/core").Children;
|
|
13
12
|
//#endregion
|
|
14
13
|
export { CommandEntry, CommandEntryProps };
|
|
15
14
|
//# sourceMappingURL=command-entry.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":";;;;UA6CiB,iBAAA,SAA0B,IAAA,CACzC,cAAA;EAGA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,YAAA,CAAa,KAAA,EAAO,iBAAiB,4BAAA,QAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
1
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
2
|
import { CommandTree } from "@shell-shock/core";
|
|
4
3
|
|
|
@@ -9,7 +8,7 @@ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinitio
|
|
|
9
8
|
/**
|
|
10
9
|
* The command entry point for the Shell Shock project.
|
|
11
10
|
*/
|
|
12
|
-
declare function CommandEntry(props: CommandEntryProps):
|
|
11
|
+
declare function CommandEntry(props: CommandEntryProps): import("@alloy-js/core").Children;
|
|
13
12
|
//#endregion
|
|
14
13
|
export { CommandEntry, CommandEntryProps };
|
|
15
14
|
//# sourceMappingURL=command-entry.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":""}
|
|
@@ -3,14 +3,13 @@ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
|
3
3
|
import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
|
|
4
4
|
import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
|
|
5
5
|
import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
6
|
+
import { joinPaths } from "@stryke/path/join";
|
|
6
7
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
8
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
9
|
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
9
|
-
import { CommandParameterKinds } from "@shell-shock/core";
|
|
10
10
|
import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
|
|
11
11
|
import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
|
|
12
12
|
import { findFilePath, relativePath } from "@stryke/path/find";
|
|
13
|
-
import { joinPaths } from "@stryke/path/join";
|
|
14
13
|
import { replaceExtension } from "@stryke/path/replace";
|
|
15
14
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
16
15
|
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
@@ -107,12 +106,12 @@ function CommandEntry(props) {
|
|
|
107
106
|
}
|
|
108
107
|
}), createComponent(Show, {
|
|
109
108
|
get when() {
|
|
110
|
-
return Object.values(command.options ?? {}).filter((option) =>
|
|
109
|
+
return Object.values(command.options ?? {}).filter((option) => option.required).length > 0 || Object.values(command.args ?? {}).filter((arg) => arg.required).length > 0;
|
|
111
110
|
},
|
|
112
111
|
get children() {
|
|
113
112
|
return createComponent(ElseIfClause, {
|
|
114
113
|
get condition() {
|
|
115
|
-
return code`!isHelp() && (${Object.values(command.options ?? {}).filter((option) =>
|
|
114
|
+
return code`!isHelp() && (${Object.values(command.options ?? {}).filter((option) => option.required).map((option) => (option.type === "string" || option.type === "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.required).length > 0 && Object.values(command.args ?? {}).filter((arg) => arg.required).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => arg.required).map((arg) => (arg.type === "string" || arg.type === "number") && arg.variadic ? `(!${camelCase(arg.name)} || ${camelCase(arg.name)}.length === 0)` : `${camelCase(arg.name)} === undefined`).join(" || ")}) `;
|
|
116
115
|
},
|
|
117
116
|
get children() {
|
|
118
117
|
return [
|
|
@@ -125,7 +124,7 @@ function CommandEntry(props) {
|
|
|
125
124
|
doubleHardline: true,
|
|
126
125
|
children: (option) => [createComponent(Show, {
|
|
127
126
|
get when() {
|
|
128
|
-
return
|
|
127
|
+
return option.required;
|
|
129
128
|
},
|
|
130
129
|
get children() {
|
|
131
130
|
return [createComponent(IfStatement, {
|
|
@@ -135,7 +134,7 @@ function CommandEntry(props) {
|
|
|
135
134
|
get children() {
|
|
136
135
|
return createComponent(Show, {
|
|
137
136
|
get when() {
|
|
138
|
-
return option.
|
|
137
|
+
return option.type === "boolean" || !option.choices || option.choices.length === 0;
|
|
139
138
|
},
|
|
140
139
|
get fallback() {
|
|
141
140
|
return code`const value = await select({
|
|
@@ -154,7 +153,7 @@ function CommandEntry(props) {
|
|
|
154
153
|
return [
|
|
155
154
|
createComponent(Match, {
|
|
156
155
|
get when() {
|
|
157
|
-
return option.
|
|
156
|
+
return option.type === "string";
|
|
158
157
|
},
|
|
159
158
|
get children() {
|
|
160
159
|
return code`
|
|
@@ -179,7 +178,7 @@ function CommandEntry(props) {
|
|
|
179
178
|
}),
|
|
180
179
|
createComponent(Match, {
|
|
181
180
|
get when() {
|
|
182
|
-
return option.
|
|
181
|
+
return option.type === "number";
|
|
183
182
|
},
|
|
184
183
|
get children() {
|
|
185
184
|
return code`
|
|
@@ -198,7 +197,7 @@ function CommandEntry(props) {
|
|
|
198
197
|
}),
|
|
199
198
|
createComponent(Match, {
|
|
200
199
|
get when() {
|
|
201
|
-
return option.
|
|
200
|
+
return option.type === "boolean";
|
|
202
201
|
},
|
|
203
202
|
get children() {
|
|
204
203
|
return code`
|
|
@@ -222,7 +221,7 @@ function CommandEntry(props) {
|
|
|
222
221
|
}
|
|
223
222
|
}), createComponent(Show, {
|
|
224
223
|
get when() {
|
|
225
|
-
return (option.
|
|
224
|
+
return (option.type === "string" || option.type === "number") && option.variadic;
|
|
226
225
|
},
|
|
227
226
|
get children() {
|
|
228
227
|
return createComponent(ElseIfClause, {
|
|
@@ -232,7 +231,7 @@ function CommandEntry(props) {
|
|
|
232
231
|
get children() {
|
|
233
232
|
return code`
|
|
234
233
|
const value = await text({
|
|
235
|
-
message: \`Please provide one or more${option.
|
|
234
|
+
message: \`Please provide one or more${option.type === "number" ? " numeric" : ""} values for the \${italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
236
235
|
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
237
236
|
` : ""}validate(val) {
|
|
238
237
|
if (!val || val.trim() === "") {
|
|
@@ -241,7 +240,7 @@ function CommandEntry(props) {
|
|
|
241
240
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
242
241
|
return "At least one value must be provided for this option";
|
|
243
242
|
}
|
|
244
|
-
${option.
|
|
243
|
+
${option.type === "number" ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
245
244
|
if (invalidIndex !== -1) {
|
|
246
245
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
247
246
|
} ` : ""}
|
|
@@ -252,7 +251,7 @@ function CommandEntry(props) {
|
|
|
252
251
|
return;
|
|
253
252
|
}
|
|
254
253
|
|
|
255
|
-
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.
|
|
254
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.type === "number" ? `.map(Number)` : ""} ;
|
|
256
255
|
`;
|
|
257
256
|
}
|
|
258
257
|
});
|
|
@@ -269,7 +268,7 @@ function CommandEntry(props) {
|
|
|
269
268
|
doubleHardline: true,
|
|
270
269
|
children: (arg) => [createComponent(Show, {
|
|
271
270
|
get when() {
|
|
272
|
-
return
|
|
271
|
+
return arg.required;
|
|
273
272
|
},
|
|
274
273
|
get children() {
|
|
275
274
|
return [createComponent(IfStatement, {
|
|
@@ -279,7 +278,7 @@ function CommandEntry(props) {
|
|
|
279
278
|
get children() {
|
|
280
279
|
return createComponent(Show, {
|
|
281
280
|
get when() {
|
|
282
|
-
return arg.
|
|
281
|
+
return arg.type === "boolean" || !arg.choices || arg.choices.length === 0;
|
|
283
282
|
},
|
|
284
283
|
get fallback() {
|
|
285
284
|
return code`const value = await select({
|
|
@@ -299,7 +298,7 @@ function CommandEntry(props) {
|
|
|
299
298
|
return [
|
|
300
299
|
createComponent(Match, {
|
|
301
300
|
get when() {
|
|
302
|
-
return arg.
|
|
301
|
+
return arg.type === "string";
|
|
303
302
|
},
|
|
304
303
|
get children() {
|
|
305
304
|
return code`
|
|
@@ -324,7 +323,7 @@ function CommandEntry(props) {
|
|
|
324
323
|
}),
|
|
325
324
|
createComponent(Match, {
|
|
326
325
|
get when() {
|
|
327
|
-
return arg.
|
|
326
|
+
return arg.type === "number";
|
|
328
327
|
},
|
|
329
328
|
get children() {
|
|
330
329
|
return code`
|
|
@@ -343,7 +342,7 @@ function CommandEntry(props) {
|
|
|
343
342
|
}),
|
|
344
343
|
createComponent(Match, {
|
|
345
344
|
get when() {
|
|
346
|
-
return arg.
|
|
345
|
+
return arg.type === "boolean";
|
|
347
346
|
},
|
|
348
347
|
get children() {
|
|
349
348
|
return code`
|
|
@@ -377,7 +376,7 @@ function CommandEntry(props) {
|
|
|
377
376
|
get children() {
|
|
378
377
|
return code`
|
|
379
378
|
const value = await text({
|
|
380
|
-
message: \`Please provide one or more${arg.
|
|
379
|
+
message: \`Please provide one or more${arg.type === "number" ? " numeric" : ""} values for the \${italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
381
380
|
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
382
381
|
` : ""}validate(val) {
|
|
383
382
|
if (!val || val.trim() === "") {
|
|
@@ -386,7 +385,7 @@ function CommandEntry(props) {
|
|
|
386
385
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
387
386
|
return "At least one value must be provided for this argument";
|
|
388
387
|
}
|
|
389
|
-
${arg.
|
|
388
|
+
${arg.type === "number" ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
390
389
|
if (invalidIndex !== -1) {
|
|
391
390
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
392
391
|
} ` : ""}
|
|
@@ -398,7 +397,7 @@ function CommandEntry(props) {
|
|
|
398
397
|
return;
|
|
399
398
|
}
|
|
400
399
|
|
|
401
|
-
${camelCase(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.
|
|
400
|
+
${camelCase(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.type === "number" ? `.map(Number)` : arg.type === "boolean" ? `.map(Boolean)` : ""} ;
|
|
402
401
|
`;
|
|
403
402
|
}
|
|
404
403
|
});
|
|
@@ -431,7 +430,7 @@ function CommandEntry(props) {
|
|
|
431
430
|
},
|
|
432
431
|
children: (child) => createComponent(Show, {
|
|
433
432
|
get when() {
|
|
434
|
-
return child.
|
|
433
|
+
return child.virtual;
|
|
435
434
|
},
|
|
436
435
|
get fallback() {
|
|
437
436
|
return createComponent(CommandEntry, { command: child });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.mjs","names":[],"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 { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\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 type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\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 { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\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<CLIPresetContext>();\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.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n { name: \"GlobalOptions\", type: true },\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp() && (${Object.values(\n command.options ?? {}\n )\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\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 <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.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`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show when={arg.variadic}>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : arg.kind === CommandParameterKinds.boolean\n ? `.map(Boolean)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\\`The following validation failures were found while processing the user provided input, and must be corrected before the \\${italic(\"${\n command.title\n }\")} command can be executed: \\\\n\\\\n\\${failures.map(failure => \" - \" + failure).join(\"\\\\n\")}\\`);\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\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":";;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAS,aAAmB,OAAO;CACnC,MAAQ,EACR,SACA,SACA,gBACA,GAAO,SACD;;CAEN,MAAO,WAAU,eAAiB,UAAS,QAAI,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CAC7C,MAAA,oBAAc,eAAA,iBAAA,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA;CACd,MAAM,iBAAI,gBAAc;EACxB,GAAA,QAAA;EACA,QAA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