@shell-shock/preset-script 0.3.2 → 0.4.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 (70) hide show
  1. package/dist/components/banner-function-declaration.cjs +101 -0
  2. package/dist/components/banner-function-declaration.cjs.map +1 -0
  3. package/dist/components/banner-function-declaration.d.cts +35 -0
  4. package/dist/components/banner-function-declaration.d.cts.map +1 -0
  5. package/dist/components/banner-function-declaration.d.mts +35 -0
  6. package/dist/components/banner-function-declaration.d.mts.map +1 -0
  7. package/dist/components/banner-function-declaration.mjs +99 -0
  8. package/dist/components/banner-function-declaration.mjs.map +1 -0
  9. package/dist/components/bin-entry.cjs +1 -1
  10. package/dist/components/bin-entry.mjs +1 -1
  11. package/dist/components/command-entry.cjs +43 -27
  12. package/dist/components/command-entry.cjs.map +1 -1
  13. package/dist/components/command-entry.d.cts +9 -7
  14. package/dist/components/command-entry.d.cts.map +1 -1
  15. package/dist/components/command-entry.d.mts +9 -7
  16. package/dist/components/command-entry.d.mts.map +1 -1
  17. package/dist/components/command-entry.mjs +43 -27
  18. package/dist/components/command-entry.mjs.map +1 -1
  19. package/dist/components/command-router.cjs +7 -28
  20. package/dist/components/command-router.cjs.map +1 -1
  21. package/dist/components/command-router.mjs +7 -28
  22. package/dist/components/command-router.mjs.map +1 -1
  23. package/dist/components/console-builtin.cjs +2 -58
  24. package/dist/components/console-builtin.cjs.map +1 -1
  25. package/dist/components/console-builtin.d.cts +3 -21
  26. package/dist/components/console-builtin.d.cts.map +1 -1
  27. package/dist/components/console-builtin.d.mts +3 -21
  28. package/dist/components/console-builtin.d.mts.map +1 -1
  29. package/dist/components/console-builtin.mjs +4 -59
  30. package/dist/components/console-builtin.mjs.map +1 -1
  31. package/dist/components/help.cjs +133 -10
  32. package/dist/components/help.cjs.map +1 -1
  33. package/dist/components/help.d.cts +48 -8
  34. package/dist/components/help.d.cts.map +1 -1
  35. package/dist/components/help.d.mts +48 -8
  36. package/dist/components/help.d.mts.map +1 -1
  37. package/dist/components/help.mjs +131 -10
  38. package/dist/components/help.mjs.map +1 -1
  39. package/dist/components/index.cjs +6 -9
  40. package/dist/components/index.d.cts +6 -6
  41. package/dist/components/index.d.mts +6 -6
  42. package/dist/components/index.mjs +4 -4
  43. package/dist/components/utils-builtin.cjs +1 -1
  44. package/dist/components/utils-builtin.d.mts +7 -7
  45. package/dist/components/utils-builtin.mjs +1 -1
  46. package/dist/components/virtual-command-entry.cjs +33 -13
  47. package/dist/components/virtual-command-entry.cjs.map +1 -1
  48. package/dist/components/virtual-command-entry.d.cts +8 -6
  49. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  50. package/dist/components/virtual-command-entry.d.mts +8 -6
  51. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  52. package/dist/components/virtual-command-entry.mjs +34 -14
  53. package/dist/components/virtual-command-entry.mjs.map +1 -1
  54. package/dist/index.cjs +20 -48
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts.map +1 -1
  57. package/dist/index.d.mts.map +1 -1
  58. package/dist/index.mjs +21 -49
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/types/plugin.d.cts.map +1 -1
  61. package/dist/types/plugin.d.mts.map +1 -1
  62. package/package.json +21 -22
  63. package/dist/components/args-parser-logic.cjs +0 -678
  64. package/dist/components/args-parser-logic.cjs.map +0 -1
  65. package/dist/components/args-parser-logic.d.cts +0 -45
  66. package/dist/components/args-parser-logic.d.cts.map +0 -1
  67. package/dist/components/args-parser-logic.d.mts +0 -45
  68. package/dist/components/args-parser-logic.d.mts.map +0 -1
  69. package/dist/components/args-parser-logic.mjs +0 -672
  70. package/dist/components/args-parser-logic.mjs.map +0 -1
@@ -3,9 +3,10 @@ const require_contexts_theme = require('../contexts/theme.cjs');
3
3
  require('../contexts/index.cjs');
4
4
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
5
  let __alloy_js_core = require("@alloy-js/core");
6
- let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
7
6
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
7
+ let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
8
8
  let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
9
+ let __shell_shock_core_components_usage = require("@shell-shock/core/components/usage");
9
10
  let __shell_shock_core_plugin_utils_reflect = require("@shell-shock/core/plugin-utils/reflect");
10
11
  let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
11
12
  let __stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
@@ -23,12 +24,18 @@ function HelpUsage(props) {
23
24
  return Object.keys(context.config.bin);
24
25
  },
25
26
  hardline: true,
26
- children: (bin) => [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
27
+ children: (bin) => [
28
+ __alloy_js_core.code`
27
29
  writeLine(
28
- colors.text.body.primary(
29
- "$ npx ${bin} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isVariableCommandPath)(segment) ? `<${command.path.variables[segment]?.variadic ? "..." : ""}${(0, __stryke_string_format_kebab_case.kebabCase)((0, __shell_shock_core_plugin_utils_context_helpers.getVariableCommandPathName)(segment))}>` : segment).join(" ")}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options]"
30
- ), { padding: ${theme.padding.app * indent} }
31
- );`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})]
30
+ colors.text.body.primary("`,
31
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_core_components_usage.Usage, {
32
+ bin,
33
+ command
34
+ }),
35
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`"), { padding: ${theme.padding.app * indent} }
36
+ );`),
37
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
38
+ ]
32
39
  });
33
40
  }
34
41
  /**
@@ -83,11 +90,11 @@ function HelpCommands(props) {
83
90
  /**
84
91
  * A component that generates the `help` function declaration for a command.
85
92
  */
86
- function Help(props) {
87
- const { command, indent = 1 } = props;
93
+ function BaseHelp(props) {
94
+ const { command, indent = 1, filterGlobalOptions = false } = props;
88
95
  const theme = require_contexts_theme.useTheme();
89
96
  const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
90
- const options = (0, __alloy_js_core.computed)(() => Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) ?? []);
97
+ const options = (0, __alloy_js_core.computed)(() => filterGlobalOptions ? Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) : Object.values(command.options));
91
98
  return [
92
99
  (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`writeLine(colors.bold(colors.text.heading.secondary("Usage:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
93
100
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
@@ -133,10 +140,126 @@ function Help(props) {
133
140
  })
134
141
  ];
135
142
  }
143
+ /**
144
+ * A component that generates the invocation of the `help` function for a command.
145
+ */
146
+ function VirtualHelp(props) {
147
+ const { options, path, commands } = props;
148
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
149
+ return [
150
+ __alloy_js_core.code`
151
+ writeLine(""); `,
152
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
153
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
154
+ __alloy_js_core.code`writeLine(colors.bold(colors.text.heading.secondary("Global Options:")));`,
155
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
156
+ (0, __alloy_js_core_jsx_runtime.createComponent)(HelpOptions, { options }),
157
+ __alloy_js_core.code`writeLine(""); `,
158
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
159
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
160
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
161
+ get when() {
162
+ return Object.keys(commands).length > 0;
163
+ },
164
+ get children() {
165
+ return [
166
+ __alloy_js_core.code`writeLine(colors.text.body.secondary("The following commands are available:"));
167
+ writeLine(""); `,
168
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
169
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
170
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
171
+ get each() {
172
+ return Object.values(commands);
173
+ },
174
+ doubleHardline: true,
175
+ joiner: __alloy_js_core.code`writeLine(""); `,
176
+ ender: __alloy_js_core.code`writeLine(""); `,
177
+ children: (child) => [
178
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
179
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
180
+ writeLine("");
181
+ writeLine(colors.text.body.secondary("${child.description}"));
182
+ writeLine("");
183
+ `),
184
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
185
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BaseHelp, {
186
+ command: child,
187
+ indent: 2,
188
+ filterGlobalOptions: true
189
+ }),
190
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
191
+ ]
192
+ }),
193
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)}${path?.segments && path.segments.length > 0 ? ` ${path.segments.join(" ")}` : ""} <specific command> --help') will provide additional information that is specific to that command.");
194
+ writeLine("");`)
195
+ ];
196
+ }
197
+ })
198
+ ];
199
+ }
200
+ /**
201
+ * A component that generates the invocation of the `help` function for a command.
202
+ */
203
+ function CommandHelp(props) {
204
+ const { command } = props;
205
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
206
+ return [
207
+ __alloy_js_core.code`writeLine(""); `,
208
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
209
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
210
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BaseHelp, {
211
+ command,
212
+ filterGlobalOptions: false
213
+ }),
214
+ __alloy_js_core.code`writeLine(""); `,
215
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
216
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
217
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
218
+ get when() {
219
+ return Object.keys(command.children).length > 0;
220
+ },
221
+ get children() {
222
+ return [
223
+ __alloy_js_core.code`writeLine(colors.text.body.secondary("The following sub-commands are available:"));
224
+ writeLine(""); `,
225
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
226
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
227
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
228
+ get each() {
229
+ return Object.values(command.children);
230
+ },
231
+ doubleHardline: true,
232
+ joiner: __alloy_js_core.code`writeLine(""); `,
233
+ ender: __alloy_js_core.code`writeLine(""); `,
234
+ children: (child) => [
235
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
236
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
237
+ writeLine("");
238
+ writeLine(colors.text.body.secondary("${child.description}"));
239
+ writeLine("");
240
+ `),
241
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
242
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BaseHelp, {
243
+ command: child,
244
+ indent: 2,
245
+ filterGlobalOptions: true
246
+ }),
247
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
248
+ ]
249
+ }),
250
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.join(" ")} <specific command> --help') will provide additional information that is specific to that command.");
251
+ writeLine("");`)
252
+ ];
253
+ }
254
+ })
255
+ ];
256
+ }
136
257
 
137
258
  //#endregion
138
- exports.Help = Help;
259
+ exports.BaseHelp = BaseHelp;
260
+ exports.CommandHelp = CommandHelp;
139
261
  exports.HelpCommands = HelpCommands;
140
262
  exports.HelpOptions = HelpOptions;
141
263
  exports.HelpUsage = HelpUsage;
264
+ exports.VirtualHelp = VirtualHelp;
142
265
  //# sourceMappingURL=help.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","usePowerlines","getVariableCommandPathName","isVariableCommandPath","sortOptions","kebabCase","snakeCase","useTheme","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","path","segments","map","segment","variables","variadic","join","values","length","padding","app","_$createIntrinsic","HelpOptions","options","option","flags","names","name","push","alias","forEach","sort","kind","string","number","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","child","Help","filter","some","globalOption","includes","when","value"],"sources":["../../src/components/help.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, Show } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { sortOptions } from \"@shell-shock/core/plugin-utils/reflect\";\nimport type {\n CommandOption,\n CommandTree\n} from \"@shell-shock/core/types/command\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { useTheme } from \"../contexts\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface HelpUsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 2\n */\n indent?: number;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function HelpUsage(props: HelpUsageProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const theme = useTheme();\n\n return (\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.primary(\n \"$ npx ${bin} ${command.path.segments\n .map(segment =>\n isVariableCommandPath(segment)\n ? `<${command.path.variables[segment]?.variadic ? \"...\" : \"\"}${kebabCase(\n getVariableCommandPathName(segment)\n )}>`\n : segment\n )\n .join(\" \")}${\n Object.values(command.children).length > 0 ? \" [commands]\" : \"\"\n } [options]\"\n ), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n );\n}\n\nexport interface HelpOptionsProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n}\n\n/**\n * A component that generates the options table display for a command.\n */\nexport function HelpOptions(props: HelpOptionsProps) {\n const { options } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={sortOptions(options)} hardline>\n {option => {\n const flags = [] as string[];\n const names = [] as string[];\n if (option.name.length === 1) {\n flags.push(`-${option.name}`);\n } else {\n names.push(`--${kebabCase(option.name)}`);\n }\n\n option.alias.forEach((alias: string) => {\n if (alias.length === 1) {\n flags.push(`-${alias}`);\n } else {\n names.push(`--${kebabCase(alias)}`);\n }\n });\n\n return code`[{ value: colors.text.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === ReflectionKind.string\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === ReflectionKind.number\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${option.description.replace(\n /\\.+$/,\n \"\"\n )} ${\n option.env || option.default !== undefined\n ? `(${\n option.env\n ? `env: ${context.config.envPrefix}_${option.env}${\n option.default !== undefined ? \", \" : \"\"\n }`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default)}`\n : \"\"\n })`\n : \"\"\n }.\"), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsProps {\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n}\n\n/**\n * A component that generates the commands table display for a command.\n */\nexport function HelpCommands(props: HelpCommandsProps) {\n const { commands } = props;\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={Object.values(commands)} hardline>\n {child =>\n code`[{ value: colors.text.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${child.description.replace(\n /\\.+$/,\n \"\"\n )}\"), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function Help(props: HelpProps) {\n const { command, indent = 1 } = props;\n\n const theme = useTheme();\n const context = usePowerlines<ScriptPresetContext>();\n\n const options = computed(\n () =>\n Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n ) ?? []\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsage command={command} indent={indent} />\n <hbr />\n <hbr />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptions options={options.value} />\n <hbr />\n <hbr />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommands commands={command.children} />\n <hbr />\n <hbr />\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuDA,SAAgBY,UAAUC,OAAuB;CAC/C,MAAM,EAAEC,SAASC,SAAS,MAAMF;CAEhC,MAAMG,8EAA8C;CACpD,MAAMC,QAAQN,iCAAU;AAExB,yDACGT,qBAAG;EAAA,IAACiB,OAAI;AAAA,UAAEC,OAAOC,KAAKL,QAAQM,OAAOC,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MAAMqB,SAASrB,MAAM,CAClE,CACJ,CAAC,IAAI,EACT,CAAC;AAED,QAAA;8CAEK9C,oBAAI,iEACHe,SAAS,IAAI,gBAAgBE,MAAMmB,QAAQC,MAAMtB,OAAM,MAAO,GAAE,IAC9D;mDAAA,OAAA,EAAA,CAAA;mDAEHH,WAAS;GAAUE;GAAiBC;GAAM,CAAA;mDAAA,OAAA,EAAA,CAAA;mDAAA,OAAA,EAAA,CAAA;mDAG1CZ,sBAAI;GAAA,IAACiE,OAAI;AAAA,WAAE5B,QAAQ6B,MAAMlC,SAAS;;GAAC,IAAAV,WAAA;AAAA,WAAA;iDACjCzB,oBAAI;wEAELe,SAAS,IAAI,gBAAgBE,MAAMmB,QAAQC,MAAMtB,OAAM,MAAO,GAAE,IAC9D;sDAAA,OAAA,EAAA,CAAA;sDAEDwB,aAAW,EAAA,IAACC,UAAO;AAAA,aAAEA,QAAQ6B;QAAK,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA;mDAIpClE,sBAAI;GAAA,IAACiE,OAAI;AAAA,WAAEhD,OAAOC,KAAKP,QAAQW,SAAS,CAACU,SAAS;;GAAC,IAAAV,WAAA;AAAA,WAAA;iDACjDzB,oBAAI;yEAELe,SAAS,IAAI,gBAAgBE,MAAMmB,QAAQC,MAAMtB,OAAM,MAAO,GAAE,IAC9D;sDAAA,OAAA,EAAA,CAAA;sDAED6C,cAAY,EAAA,IAACC,WAAQ;AAAA,aAAE/C,QAAQW;QAAQ,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA;EAAA"}
1
+ {"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","usePowerlines","Usage","getAppBin","sortOptions","kebabCase","snakeCase","useTheme","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","padding","app","_$createIntrinsic","HelpOptions","options","option","flags","names","name","length","push","alias","forEach","sort","join","kind","string","variadic","number","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","values","child","BaseHelp","filterGlobalOptions","filter","some","globalOption","includes","when","value","VirtualHelp","path","doubleHardline","joiner","ender","title","isVirtual","segments","CommandHelp"],"sources":["../../src/components/help.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, Show } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { Usage } from \"@shell-shock/core/components/usage\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { sortOptions } from \"@shell-shock/core/plugin-utils/reflect\";\nimport type {\n CommandOption,\n CommandTree,\n CommandTreePath\n} from \"@shell-shock/core/types/command\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { useTheme } from \"../contexts\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface HelpUsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 2\n */\n indent?: number;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function HelpUsage(props: HelpUsageProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const theme = useTheme();\n\n return (\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.primary(\"`}\n <Usage bin={bin} command={command} />\n {code`\"), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n );\n}\n\nexport interface HelpOptionsProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n}\n\n/**\n * A component that generates the options table display for a command.\n */\nexport function HelpOptions(props: HelpOptionsProps) {\n const { options } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={sortOptions(options)} hardline>\n {option => {\n const flags = [] as string[];\n const names = [] as string[];\n if (option.name.length === 1) {\n flags.push(`-${option.name}`);\n } else {\n names.push(`--${kebabCase(option.name)}`);\n }\n\n option.alias.forEach((alias: string) => {\n if (alias.length === 1) {\n flags.push(`-${alias}`);\n } else {\n names.push(`--${kebabCase(alias)}`);\n }\n });\n\n return code`[{ value: colors.text.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === ReflectionKind.string\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === ReflectionKind.number\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${option.description.replace(\n /\\.+$/,\n \"\"\n )} ${\n option.env || option.default !== undefined\n ? `(${\n option.env\n ? `env: ${context.config.envPrefix}_${option.env}${\n option.default !== undefined ? \", \" : \"\"\n }`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default)}`\n : \"\"\n })`\n : \"\"\n }.\"), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsProps {\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n}\n\n/**\n * A component that generates the commands table display for a command.\n */\nexport function HelpCommands(props: HelpCommandsProps) {\n const { commands } = props;\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={Object.values(commands)} hardline>\n {child =>\n code`[{ value: colors.text.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${child.description.replace(\n /\\.+$/,\n \"\"\n )}\"), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * Whether to filter out global options from the help display.\n *\n * @remarks\n * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.\n *\n * @defaultValue false\n */\n filterGlobalOptions?: boolean;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function BaseHelp(props: BaseHelpProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<ScriptPresetContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n )\n : Object.values(command.options)\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsage command={command} indent={indent} />\n <hbr />\n <hbr />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptions options={options.value} />\n <hbr />\n <hbr />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommands commands={command.children} />\n <hbr />\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface VirtualHelpProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n\n /**\n * The command path to generate help for, used for generating the help invocation instructions.\n *\n * @remarks\n * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).\n */\n path?: CommandTreePath;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualHelp(props: VirtualHelpProps) {\n const { options, path, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptions options={options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${\n child.isVirtual ? \"\" : \"Command\"\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )}${\n path?.segments && path.segments.length > 0\n ? ` ${path.segments.join(\" \")}`\n : \"\"\n } <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpProps {\n /**\n * A mapping of command names to their command definitions.\n */\n command: CommandTree;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function CommandHelp(props: CommandHelpProps) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <BaseHelp command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${\n child.isVirtual ? \"\" : \"Command\"\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )} ${command.path.segments.join(\" \")} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,SAAgBY,UAAUC,OAAuB;CAC/C,MAAM,EAAEC,SAASC,SAAS,MAAMF;CAEhC,MAAMG,8EAA8C;CACpD,MAAMC,QAAQN,iCAAU;AAExB,yDACGT,qBAAG;EAAA,IAACiB,OAAI;AAAA,UAAEC,OAAOC,KAAKL,QAAQM,OAAOC,IAAI;;EAAEC,UAAQ;EAA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AAA,cAAEC,OAAOoC,OAAO1C,QAAQW,SAAS;;MACrC2C,gBAAc;MACdC,QAAQrE,oBAAI;MACZsE,OAAOtE,oBAAI;MAAiByB,WAC3BgC,UAAK;mDAEDzD,oBAAI;yDACsCyD,MAAMc,MAAK,GAClDd,MAAMe,YAAY,KAAK,UAAS;;wDAGMf,MAAMX,YAAW;;kBAExD;wDAAA,OAAA,EAAA,CAAA;wDAEFY,UAAQ;QAAC5C,SAAS2C;QAAO1C,QAAQ;QAAG4C,qBAAmB;QAAA,CAAA;wDAAA,OAAA,EAAA,CAAA;OAAA;MAG3D,CAAA;iDAEF3D,oBAAI,6HACHgB,QACD,CAAA,GAAIF,QAAQqD,KAAKM,SAAShC,KAAK,IAAI,CAAA;wBACrB;KAAA;;GAAA,CAAA;EAAA"}
@@ -1,5 +1,5 @@
1
- import * as _alloy_js_core16 from "@alloy-js/core";
2
- import { CommandOption, CommandTree } from "@shell-shock/core/types/command";
1
+ import * as _alloy_js_core5 from "@alloy-js/core";
2
+ import { CommandOption, CommandTree, CommandTreePath } from "@shell-shock/core/types/command";
3
3
 
4
4
  //#region src/components/help.d.ts
5
5
  interface HelpUsageProps {
@@ -20,7 +20,7 @@ interface HelpUsageProps {
20
20
  /**
21
21
  * A component that generates the usage display for a command.
22
22
  */
23
- declare function HelpUsage(props: HelpUsageProps): _alloy_js_core16.Children;
23
+ declare function HelpUsage(props: HelpUsageProps): _alloy_js_core5.Children;
24
24
  interface HelpOptionsProps {
25
25
  /**
26
26
  * The options to display help for.
@@ -30,7 +30,7 @@ interface HelpOptionsProps {
30
30
  /**
31
31
  * A component that generates the options table display for a command.
32
32
  */
33
- declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core16.Children;
33
+ declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core5.Children;
34
34
  interface HelpCommandsProps {
35
35
  /**
36
36
  * A mapping of command names to their command definitions.
@@ -40,12 +40,21 @@ interface HelpCommandsProps {
40
40
  /**
41
41
  * A component that generates the commands table display for a command.
42
42
  */
43
- declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core16.Children;
44
- interface HelpProps {
43
+ declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core5.Children;
44
+ interface BaseHelpProps {
45
45
  /**
46
46
  * The command to generate help for.
47
47
  */
48
48
  command: CommandTree;
49
+ /**
50
+ * Whether to filter out global options from the help display.
51
+ *
52
+ * @remarks
53
+ * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.
54
+ *
55
+ * @defaultValue false
56
+ */
57
+ filterGlobalOptions?: boolean;
49
58
  /**
50
59
  * The padding scale to apply to the help display headings.
51
60
  *
@@ -59,7 +68,38 @@ interface HelpProps {
59
68
  /**
60
69
  * A component that generates the `help` function declaration for a command.
61
70
  */
62
- declare function Help(props: HelpProps): _alloy_js_core16.Children;
71
+ declare function BaseHelp(props: BaseHelpProps): _alloy_js_core5.Children;
72
+ interface VirtualHelpProps {
73
+ /**
74
+ * The options to display help for.
75
+ */
76
+ options: CommandOption[];
77
+ /**
78
+ * A mapping of command names to their command definitions.
79
+ */
80
+ commands: Record<string, CommandTree>;
81
+ /**
82
+ * The command path to generate help for, used for generating the help invocation instructions.
83
+ *
84
+ * @remarks
85
+ * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).
86
+ */
87
+ path?: CommandTreePath;
88
+ }
89
+ /**
90
+ * A component that generates the invocation of the `help` function for a command.
91
+ */
92
+ declare function VirtualHelp(props: VirtualHelpProps): _alloy_js_core5.Children;
93
+ interface CommandHelpProps {
94
+ /**
95
+ * A mapping of command names to their command definitions.
96
+ */
97
+ command: CommandTree;
98
+ }
99
+ /**
100
+ * A component that generates the invocation of the `help` function for a command.
101
+ */
102
+ declare function CommandHelp(props: CommandHelpProps): _alloy_js_core5.Children;
63
103
  //#endregion
64
- export { Help, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpProps, HelpUsage, HelpUsageProps };
104
+ export { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps };
65
105
  //# sourceMappingURL=help.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.cts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAmCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAiCR;AAUjB;AA+DA;AAUA;AAuBA;AAoBA;;;;;;;;iBA/JgB,SAAA,QAAiB,iBAAc,gBAAA,CAAA;UAiC9B,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,gBAAA,CAAA;UA+DlC,iBAAA;;;;YAIL,eAAe;;;;;iBAMX,YAAA,QAAoB,oBAAiB,gBAAA,CAAA;UAuBpC,SAAA;;;;WAIN;;;;;;;;;;;;;;iBAgBK,IAAA,QAAY,YAAS,gBAAA,CAAA"}
1
+ {"version":3,"file":"help.d.cts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAkCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAuBR;AAUjB;AA+DA;AAUA;AAuBA;AA8BA;AAsDA;;EAS2B,MAAA,CAAA,EAAA,MAAA;;;;AAc3B;AAwDiB,iBApSD,SAAA,CAoSiB,KAItB,EAxSsB,cAwSX,CAAA,EAxSyB,eAAA,CAAA,QAwSzB;AAMN,UAvRC,gBAAA,CAuRkB;;;;WAnRxB;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UA+DlC,iBAAA;;;;YAIL,eAAe;;;;;iBAMX,YAAA,QAAoB,oBAAiB,eAAA,CAAA;UAuBpC,aAAA;;;;WAIN;;;;;;;;;;;;;;;;;;;;;;;iBA0BK,QAAA,QAAgB,gBAAa,eAAA,CAAA;UAsD5B,gBAAA;;;;WAIN;;;;YAKC,eAAe;;;;;;;SAQlB;;;;;iBAMO,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UAwDlC,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import * as _alloy_js_core7 from "@alloy-js/core";
2
- import { CommandOption, CommandTree } from "@shell-shock/core/types/command";
1
+ import * as _alloy_js_core5 from "@alloy-js/core";
2
+ import { CommandOption, CommandTree, CommandTreePath } from "@shell-shock/core/types/command";
3
3
 
4
4
  //#region src/components/help.d.ts
5
5
  interface HelpUsageProps {
@@ -20,7 +20,7 @@ interface HelpUsageProps {
20
20
  /**
21
21
  * A component that generates the usage display for a command.
22
22
  */
23
- declare function HelpUsage(props: HelpUsageProps): _alloy_js_core7.Children;
23
+ declare function HelpUsage(props: HelpUsageProps): _alloy_js_core5.Children;
24
24
  interface HelpOptionsProps {
25
25
  /**
26
26
  * The options to display help for.
@@ -30,7 +30,7 @@ interface HelpOptionsProps {
30
30
  /**
31
31
  * A component that generates the options table display for a command.
32
32
  */
33
- declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core7.Children;
33
+ declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core5.Children;
34
34
  interface HelpCommandsProps {
35
35
  /**
36
36
  * A mapping of command names to their command definitions.
@@ -40,12 +40,21 @@ interface HelpCommandsProps {
40
40
  /**
41
41
  * A component that generates the commands table display for a command.
42
42
  */
43
- declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core7.Children;
44
- interface HelpProps {
43
+ declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core5.Children;
44
+ interface BaseHelpProps {
45
45
  /**
46
46
  * The command to generate help for.
47
47
  */
48
48
  command: CommandTree;
49
+ /**
50
+ * Whether to filter out global options from the help display.
51
+ *
52
+ * @remarks
53
+ * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.
54
+ *
55
+ * @defaultValue false
56
+ */
57
+ filterGlobalOptions?: boolean;
49
58
  /**
50
59
  * The padding scale to apply to the help display headings.
51
60
  *
@@ -59,7 +68,38 @@ interface HelpProps {
59
68
  /**
60
69
  * A component that generates the `help` function declaration for a command.
61
70
  */
62
- declare function Help(props: HelpProps): _alloy_js_core7.Children;
71
+ declare function BaseHelp(props: BaseHelpProps): _alloy_js_core5.Children;
72
+ interface VirtualHelpProps {
73
+ /**
74
+ * The options to display help for.
75
+ */
76
+ options: CommandOption[];
77
+ /**
78
+ * A mapping of command names to their command definitions.
79
+ */
80
+ commands: Record<string, CommandTree>;
81
+ /**
82
+ * The command path to generate help for, used for generating the help invocation instructions.
83
+ *
84
+ * @remarks
85
+ * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).
86
+ */
87
+ path?: CommandTreePath;
88
+ }
89
+ /**
90
+ * A component that generates the invocation of the `help` function for a command.
91
+ */
92
+ declare function VirtualHelp(props: VirtualHelpProps): _alloy_js_core5.Children;
93
+ interface CommandHelpProps {
94
+ /**
95
+ * A mapping of command names to their command definitions.
96
+ */
97
+ command: CommandTree;
98
+ }
99
+ /**
100
+ * A component that generates the invocation of the `help` function for a command.
101
+ */
102
+ declare function CommandHelp(props: CommandHelpProps): _alloy_js_core5.Children;
63
103
  //#endregion
64
- export { Help, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpProps, HelpUsage, HelpUsageProps };
104
+ export { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps };
65
105
  //# sourceMappingURL=help.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.mts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAmCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAiCR;AAUjB;AA+DA;AAUA;AAuBA;AAoBA;;;;;;;;iBA/JgB,SAAA,QAAiB,iBAAc,eAAA,CAAA;UAiC9B,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UA+DlC,iBAAA;;;;YAIL,eAAe;;;;;iBAMX,YAAA,QAAoB,oBAAiB,eAAA,CAAA;UAuBpC,SAAA;;;;WAIN;;;;;;;;;;;;;;iBAgBK,IAAA,QAAY,YAAS,eAAA,CAAA"}
1
+ {"version":3,"file":"help.d.mts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAkCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAuBR;AAUjB;AA+DA;AAUA;AAuBA;AA8BA;AAsDA;;EAS2B,MAAA,CAAA,EAAA,MAAA;;;;AAc3B;AAwDiB,iBApSD,SAAA,CAoSiB,KAItB,EAxSsB,cAwSX,CAAA,EAxSyB,eAAA,CAAA,QAwSzB;AAMN,UAvRC,gBAAA,CAuRkB;;;;WAnRxB;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UA+DlC,iBAAA;;;;YAIL,eAAe;;;;;iBAMX,YAAA,QAAoB,oBAAiB,eAAA,CAAA;UAuBpC,aAAA;;;;WAIN;;;;;;;;;;;;;;;;;;;;;;;iBA0BK,QAAA,QAAgB,gBAAa,eAAA,CAAA;UAsD5B,gBAAA;;;;WAIN;;;;YAKC,eAAe;;;;;;;SAQlB;;;;;iBAMO,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UAwDlC,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA"}
@@ -2,9 +2,10 @@ import { useTheme } from "../contexts/theme.mjs";
2
2
  import "../contexts/index.mjs";
3
3
  import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
4
4
  import { For, Show, code, computed } from "@alloy-js/core";
5
- import { getVariableCommandPathName, isVariableCommandPath } from "@shell-shock/core/plugin-utils/context-helpers";
6
5
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
6
+ import { getAppBin } from "@shell-shock/core/plugin-utils/context-helpers";
7
7
  import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
8
+ import { Usage } from "@shell-shock/core/components/usage";
8
9
  import { sortOptions } from "@shell-shock/core/plugin-utils/reflect";
9
10
  import { kebabCase } from "@stryke/string-format/kebab-case";
10
11
  import { snakeCase } from "@stryke/string-format/snake-case";
@@ -22,12 +23,18 @@ function HelpUsage(props) {
22
23
  return Object.keys(context.config.bin);
23
24
  },
24
25
  hardline: true,
25
- children: (bin) => [memo(() => code`
26
+ children: (bin) => [
27
+ code`
26
28
  writeLine(
27
- colors.text.body.primary(
28
- "$ npx ${bin} ${command.path.segments.map((segment) => isVariableCommandPath(segment) ? `<${command.path.variables[segment]?.variadic ? "..." : ""}${kebabCase(getVariableCommandPathName(segment))}>` : segment).join(" ")}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options]"
29
- ), { padding: ${theme.padding.app * indent} }
30
- );`), createIntrinsic("hbr", {})]
29
+ colors.text.body.primary("`,
30
+ createComponent(Usage, {
31
+ bin,
32
+ command
33
+ }),
34
+ memo(() => code`"), { padding: ${theme.padding.app * indent} }
35
+ );`),
36
+ createIntrinsic("hbr", {})
37
+ ]
31
38
  });
32
39
  }
33
40
  /**
@@ -82,11 +89,11 @@ function HelpCommands(props) {
82
89
  /**
83
90
  * A component that generates the `help` function declaration for a command.
84
91
  */
85
- function Help(props) {
86
- const { command, indent = 1 } = props;
92
+ function BaseHelp(props) {
93
+ const { command, indent = 1, filterGlobalOptions = false } = props;
87
94
  const theme = useTheme();
88
95
  const context = usePowerlines();
89
- const options = computed(() => Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) ?? []);
96
+ const options = computed(() => filterGlobalOptions ? Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) : Object.values(command.options));
90
97
  return [
91
98
  memo(() => code`writeLine(colors.bold(colors.text.heading.secondary("Usage:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
92
99
  createIntrinsic("hbr", {}),
@@ -132,7 +139,121 @@ function Help(props) {
132
139
  })
133
140
  ];
134
141
  }
142
+ /**
143
+ * A component that generates the invocation of the `help` function for a command.
144
+ */
145
+ function VirtualHelp(props) {
146
+ const { options, path, commands } = props;
147
+ const context = usePowerlines();
148
+ return [
149
+ code`
150
+ writeLine(""); `,
151
+ createIntrinsic("hbr", {}),
152
+ createIntrinsic("hbr", {}),
153
+ code`writeLine(colors.bold(colors.text.heading.secondary("Global Options:")));`,
154
+ createIntrinsic("hbr", {}),
155
+ createComponent(HelpOptions, { options }),
156
+ code`writeLine(""); `,
157
+ createIntrinsic("hbr", {}),
158
+ createIntrinsic("hbr", {}),
159
+ createComponent(Show, {
160
+ get when() {
161
+ return Object.keys(commands).length > 0;
162
+ },
163
+ get children() {
164
+ return [
165
+ code`writeLine(colors.text.body.secondary("The following commands are available:"));
166
+ writeLine(""); `,
167
+ createIntrinsic("hbr", {}),
168
+ createIntrinsic("hbr", {}),
169
+ createComponent(For, {
170
+ get each() {
171
+ return Object.values(commands);
172
+ },
173
+ doubleHardline: true,
174
+ joiner: code`writeLine(""); `,
175
+ ender: code`writeLine(""); `,
176
+ children: (child) => [
177
+ memo(() => code`
178
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
179
+ writeLine("");
180
+ writeLine(colors.text.body.secondary("${child.description}"));
181
+ writeLine("");
182
+ `),
183
+ createIntrinsic("hbr", {}),
184
+ createComponent(BaseHelp, {
185
+ command: child,
186
+ indent: 2,
187
+ filterGlobalOptions: true
188
+ }),
189
+ createIntrinsic("hbr", {})
190
+ ]
191
+ }),
192
+ memo(() => code`help("Running a specific command with the help flag (via: '${getAppBin(context)}${path?.segments && path.segments.length > 0 ? ` ${path.segments.join(" ")}` : ""} <specific command> --help') will provide additional information that is specific to that command.");
193
+ writeLine("");`)
194
+ ];
195
+ }
196
+ })
197
+ ];
198
+ }
199
+ /**
200
+ * A component that generates the invocation of the `help` function for a command.
201
+ */
202
+ function CommandHelp(props) {
203
+ const { command } = props;
204
+ const context = usePowerlines();
205
+ return [
206
+ code`writeLine(""); `,
207
+ createIntrinsic("hbr", {}),
208
+ createIntrinsic("hbr", {}),
209
+ createComponent(BaseHelp, {
210
+ command,
211
+ filterGlobalOptions: false
212
+ }),
213
+ code`writeLine(""); `,
214
+ createIntrinsic("hbr", {}),
215
+ createIntrinsic("hbr", {}),
216
+ createComponent(Show, {
217
+ get when() {
218
+ return Object.keys(command.children).length > 0;
219
+ },
220
+ get children() {
221
+ return [
222
+ code`writeLine(colors.text.body.secondary("The following sub-commands are available:"));
223
+ writeLine(""); `,
224
+ createIntrinsic("hbr", {}),
225
+ createIntrinsic("hbr", {}),
226
+ createComponent(For, {
227
+ get each() {
228
+ return Object.values(command.children);
229
+ },
230
+ doubleHardline: true,
231
+ joiner: code`writeLine(""); `,
232
+ ender: code`writeLine(""); `,
233
+ children: (child) => [
234
+ memo(() => code`
235
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
236
+ writeLine("");
237
+ writeLine(colors.text.body.secondary("${child.description}"));
238
+ writeLine("");
239
+ `),
240
+ createIntrinsic("hbr", {}),
241
+ createComponent(BaseHelp, {
242
+ command: child,
243
+ indent: 2,
244
+ filterGlobalOptions: true
245
+ }),
246
+ createIntrinsic("hbr", {})
247
+ ]
248
+ }),
249
+ memo(() => code`help("Running a specific command with the help flag (via: '${getAppBin(context)} ${command.path.segments.join(" ")} <specific command> --help') will provide additional information that is specific to that command.");
250
+ writeLine("");`)
251
+ ];
252
+ }
253
+ })
254
+ ];
255
+ }
135
256
 
136
257
  //#endregion
137
- export { Help, HelpCommands, HelpOptions, HelpUsage };
258
+ export { BaseHelp, CommandHelp, HelpCommands, HelpOptions, HelpUsage, VirtualHelp };
138
259
  //# sourceMappingURL=help.mjs.map