@shell-shock/plugin-help 0.2.26 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,276 @@
1
- import{createComponent as e,createIntrinsic as t,memo as n}from"@alloy-js/core/jsx-runtime";import{For as r,Show as i,code as a,computed as o}from"@alloy-js/core";import{formatDescription as s,formatShortDescription as c,getAppBin as l,getAppTitle as u,getDynamicPathSegmentName as d,isDynamicPathSegment as f,sortOptions as p}from"@shell-shock/core/plugin-utils";import{isSetString as m}from"@stryke/type-checks/is-set-string";import{Spacing as h}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as g}from"@powerlines/plugin-alloy/core/contexts/context";import{CommandParameterKinds as _}from"@shell-shock/core";import{useTheme as v}from"@shell-shock/plugin-theme/contexts/theme";import{camelCase as y}from"@stryke/string-format/camel-case";import{kebabCase as b}from"@stryke/string-format/kebab-case";import{snakeCase as x}from"@stryke/string-format/snake-case";function S(r){let{command:o,indent:s=2}=r,c=g(),u=v();return[n(()=>a`
1
+ import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { For, Show, code, computed } from "@alloy-js/core";
3
+ import { formatDescription, formatShortDescription, getAppBin, getAppTitle, getDynamicPathSegmentName, isDynamicPathSegment, sortOptions } from "@shell-shock/core/plugin-utils";
4
+ import { isSetString } from "@stryke/type-checks/is-set-string";
5
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
+ import { CommandParameterKinds } from "@shell-shock/core";
8
+ import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
9
+ import { camelCase } from "@stryke/string-format/camel-case";
10
+ import { kebabCase } from "@stryke/string-format/kebab-case";
11
+ import { snakeCase } from "@stryke/string-format/snake-case";
12
+
13
+ //#region src/components/display.tsx
14
+ /**
15
+ * A component that generates the usage display for a command.
16
+ */
17
+ function HelpUsageDisplay(props) {
18
+ const { command, indent = 2 } = props;
19
+ const context = usePowerlines();
20
+ const theme = useTheme();
21
+ return [
22
+ memo(() => code`
2
23
  writeLine(
3
- textColors.body.secondary(\`\${textColors.usage.bin("$_ ${l(c)}")}${o.segments.length>0?` ${o.segments.map(e=>`\${textColors.usage.${f(e)?`dynamic`:`command`}("${f(e)?`[${x(d(e))}]`:e}")}`).join(` `)}`:``}${Object.values(o.children).length>0?' ${textColors.usage.dynamic("[command]")}':``}${o.args.length>0?` ${o.args.map(e=>`\${textColors.usage.args("<${x((e.kind===_.string||e.kind===_.number)&&e.choices&&e.choices.length>0?e.choices.join(`|`):e.kind===_.string&&e.format?e.format:e.name)}${(e.kind===_.string||e.kind===_.number)&&e.variadic?`...`:``}>")}`).join(` `)}`:``} \${textColors.usage.options("[options]")}\`), { padding: ${u.padding.app*s} }
4
- );`),t(`hbr`,{}),e(i,{get when(){return o.args.length>0},get children(){return[t(`hbr`,{}),n(()=>a`
24
+ textColors.body.secondary(\`\${textColors.usage.bin("$_ ${getAppBin(context)}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${textColors.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${textColors.usage.dynamic("[command]")}` : ""}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${textColors.usage.args("<${snakeCase((arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""} \${textColors.usage.options("[options]")}\`), { padding: ${theme.padding.app * indent} }
25
+ );`),
26
+ createIntrinsic("hbr", {}),
27
+ createComponent(Show, {
28
+ get when() {
29
+ return command.args.length > 0;
30
+ },
31
+ get children() {
32
+ return [
33
+ createIntrinsic("hbr", {}),
34
+ memo(() => code`
5
35
  writeLine(
6
- textColors.body.secondary(\`\${textColors.usage.bin("$_ ${l(c)}")}${o.segments.length>0?` ${o.segments.map(e=>`\${textColors.usage.${f(e)?`dynamic`:`command`}("${f(e)?`[${x(d(e))}]`:e}")}`).join(` `)}`:``}${Object.values(o.children).length>0?' ${textColors.usage.dynamic("[command]")}':``} \${textColors.usage.options("[options]")}${o.args.length>0?` ${o.args.map(e=>`\${textColors.usage.args("<${x((e.kind===_.string||e.kind===_.number)&&e.choices&&e.choices.length>0?e.choices.join(`|`):e.kind===_.string&&e.format?e.format:e.name)}${(e.kind===_.string||e.kind===_.number)&&e.variadic?`...`:``}>")}`).join(` `)}`:``}\`), { padding: ${u.padding.app*s} }
7
- );`),t(`hbr`,{})]}})]}function C(n){let{options:i}=n,o=g();return[a`table([ `,t(`hbr`,{}),e(r,{get each(){return p(i)},hardline:!0,children:e=>{let t=[],n=[];return e.name.length===1?t.push(`-${e.name}`):n.push(`--${b(e.name)}`),e.alias.forEach(e=>{e.length===1?t.push(`-${e}`):n.push(`--${b(e)}`)}),a`[{ value: textColors.body.primary("${t.length>0?`${t.sort().join(`, `)}${n.length>0?`, `:``}`:``}${n.length>0?n.sort().join(`, `):``}${e.kind===_.string?` <${x(e.choices&&e.choices.length>0?e.choices.join(`|`):e.format?e.format:e.name)}${e.variadic?`...`:``}>`:e.kind===_.number?` <${x(e.choices&&e.choices.length>0?e.choices.join(`|`):e.name)}${e.variadic?`...`:``}>`:``}"), align: "right", border: "none", maxWidth: "1/3" }, { value: textColors.body.tertiary(\`${c(e.description,{length:200}).replace(/\.+$/,``).trim()}${e.env||e.default!==void 0?` (${e.env?`env: ${o.config.appSpecificEnvPrefix}_${e.env}${e.default===void 0?``:`, `}`:``}${e.default===void 0?``:`default: ${JSON.stringify(e.default).replace(/"/g,`\\"`)}`})`:``}.\`), align: "left", border: "none" }], `}}),t(`hbr`,{}),a` ]); `]}function w(n){let{commands:i}=n;return[a`table([ `,t(`hbr`,{}),e(r,{get each(){return Object.values(i)},hardline:!0,children:e=>a`[{ value: textColors.body.primary("${e.name}"), align: "right", border: "none" }, { value: textColors.body.tertiary(\`${c(e.description,{length:200}).replace(/\.+$/,``).trim()}.\`), align: "left", border: "none" }], `}),t(`hbr`,{}),a` ]); `]}function T(r){let{command:s,indent:c=1,filterGlobalOptions:l=!1}=r,u=v(),d=g(),f=o(()=>l?Object.values(s.options).filter(e=>!d.globalOptions.some(t=>t.name===e.name||e.alias.includes(t.name)||t.alias?.includes(e.name)||t.alias?.some(t=>e.alias.includes(t)))):Object.values(s.options));return[n(()=>a`writeLine(bold(textColors.heading.secondary("Usage:"))${c>1?`, { padding: ${u.padding.app*c} }`:``});`),t(`hbr`,{}),e(S,{command:s,indent:c}),e(h,{}),e(i,{get when(){return f.value.length>0},get children(){return[n(()=>a`writeLine("");
8
- writeLine(bold(textColors.heading.secondary("Options:"))${c>1?`, { padding: ${u.padding.app*c} }`:``});`),t(`hbr`,{}),e(C,{get options(){return f.value}}),e(h,{})]}}),e(i,{get when(){return Object.keys(s.children).length>0},get children(){return[n(()=>a`writeLine("");
9
- writeLine(bold(textColors.heading.secondary("Commands:"))${c>1?`, { padding: ${u.padding.app*c} }`:``});`),t(`hbr`,{}),e(w,{get commands(){return s.children}}),e(h,{})]}}),e(i,{get when(){return m(s.reference)},get children(){return[n(()=>a`writeLine("");
10
- writeLine(textColors.heading.tertiary(\`More information about this command can be found in the reference documentation at \${link("${s.reference}")}\`)${c>1?`, { padding: ${u.padding.app*c} }`:``});`),t(`hbr`,{}),e(h,{})]}})]}function E(e){return Object.values(e).sort((e,t)=>e.tags.some(e=>e.toLowerCase()===`deprecated`)&&!t.tags.some(e=>e.toLowerCase()===`deprecated`)?1:!e.tags.some(e=>e.toLowerCase()===`deprecated`)&&t.tags.some(e=>e.toLowerCase()===`deprecated`)?-1:e.tags.some(e=>e.toLowerCase()===`experimental`)&&!t.tags.some(e=>e.toLowerCase()===`experimental`)?1:!e.tags.some(e=>e.toLowerCase()===`experimental`)&&t.tags.some(e=>e.toLowerCase()===`experimental`)?-1:e.tags.some(e=>e.toLowerCase()===`utility`)&&!t.tags.some(e=>e.toLowerCase()===`utility`)?1:!e.tags.some(e=>e.toLowerCase()===`utility`)&&t.tags.some(e=>e.toLowerCase()===`utility`)?-1:e.name.localeCompare(t.name))}function D(o){let{options:c,segments:d,commands:f}=o,p=g();return[t(`hbr`,{}),a`writeLine(bold(textColors.heading.secondary("Common Options:")));`,t(`hbr`,{}),e(C,{options:c}),a`writeLine(""); `,e(h,{}),e(i,{get when(){return Object.keys(f).length>0},get children(){return[n(()=>a`writeLine(textColors.body.tertiary("The following commands are available through the ${u(p,!0)} command-line interface:"));
11
- writeLine(""); `),e(h,{}),e(r,{get each(){return E(f)},doubleHardline:!0,joiner:a`writeLine(""); `,ender:a`writeLine(""); `,children:r=>[t(`hbr`,{}),n(()=>a`
12
- writeLine(textColors.heading.primary(${r.icon?`(isUnicodeSupported ? " ${r.icon} " : "") + `:``}\`${r.title} ${r.isVirtual?``:`Command`}${r.tags?.length>0?` - ${r.tags.map(e=>`\${textColors.tags.${y(e)} ? textColors.tags.${y(e)}(inverse(" ${e} ")) : textColors.tags.$default(inverse(" ${e} "))}`).join(` `)}`:``}\`));
36
+ textColors.body.secondary(\`\${textColors.usage.bin("$_ ${getAppBin(context)}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${textColors.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${textColors.usage.dynamic("[command]")}` : ""} \${textColors.usage.options("[options]")}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${textColors.usage.args("<${snakeCase((arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""}\`), { padding: ${theme.padding.app * indent} }
37
+ );`),
38
+ createIntrinsic("hbr", {})
39
+ ];
40
+ }
41
+ })
42
+ ];
43
+ }
44
+ /**
45
+ * A component that generates the options table display for a command.
46
+ */
47
+ function HelpOptionsDisplay(props) {
48
+ const { options } = props;
49
+ const context = usePowerlines();
50
+ return [
51
+ code`table([ `,
52
+ createIntrinsic("hbr", {}),
53
+ createComponent(For, {
54
+ get each() {
55
+ return sortOptions(options);
56
+ },
57
+ hardline: true,
58
+ children: (option) => {
59
+ const flags = [];
60
+ const names = [];
61
+ if (option.name.length === 1) flags.push(`-${option.name}`);
62
+ else names.push(`--${kebabCase(option.name)}`);
63
+ option.alias.forEach((alias) => {
64
+ if (alias.length === 1) flags.push(`-${alias}`);
65
+ else names.push(`--${kebabCase(alias)}`);
66
+ });
67
+ return code`[{ value: textColors.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind === CommandParameterKinds.string ? ` <${snakeCase(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.format ? option.format : option.name)}${option.variadic ? "..." : ""}>` : option.kind === CommandParameterKinds.number ? ` <${snakeCase(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.name)}${option.variadic ? "..." : ""}>` : ""}"), align: "right", border: "none", maxWidth: "1/3" }, { value: textColors.body.tertiary(\`${formatShortDescription(option.description, { length: 200 }).replace(/\.+$/, "").trim()}${option.env || option.default !== void 0 ? ` (${option.env ? `env: ${context.config.appSpecificEnvPrefix}_${option.env}${option.default !== void 0 ? ", " : ""}` : ""}${option.default !== void 0 ? `default: ${JSON.stringify(option.default).replace(/"/g, "\\\"")}` : ""})` : ""}.\`), align: "left", border: "none" }], `;
68
+ }
69
+ }),
70
+ createIntrinsic("hbr", {}),
71
+ code` ]); `
72
+ ];
73
+ }
74
+ /**
75
+ * A component that generates the commands table display for a command.
76
+ */
77
+ function HelpCommandsDisplay(props) {
78
+ const { commands } = props;
79
+ return [
80
+ code`table([ `,
81
+ createIntrinsic("hbr", {}),
82
+ createComponent(For, {
83
+ get each() {
84
+ return Object.values(commands);
85
+ },
86
+ hardline: true,
87
+ children: (child) => code`[{ value: textColors.body.primary("${child.name}"), align: "right", border: "none" }, { value: textColors.body.tertiary(\`${formatShortDescription(child.description, { length: 200 }).replace(/\.+$/, "").trim()}.\`), align: "left", border: "none" }], `
88
+ }),
89
+ createIntrinsic("hbr", {}),
90
+ code` ]); `
91
+ ];
92
+ }
93
+ /**
94
+ * A component that generates the `help` function declaration for a command.
95
+ */
96
+ function BaseHelpDisplay(props) {
97
+ const { command, indent = 1, filterGlobalOptions = false } = props;
98
+ const theme = useTheme();
99
+ const context = usePowerlines();
100
+ const options = computed(() => filterGlobalOptions ? Object.values(command.options).filter((option) => !context.globalOptions.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));
101
+ return [
102
+ memo(() => code`writeLine(bold(textColors.heading.secondary("Usage:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
103
+ createIntrinsic("hbr", {}),
104
+ createComponent(HelpUsageDisplay, {
105
+ command,
106
+ indent
107
+ }),
108
+ createComponent(Spacing, {}),
109
+ createComponent(Show, {
110
+ get when() {
111
+ return options.value.length > 0;
112
+ },
113
+ get children() {
114
+ return [
115
+ memo(() => code`writeLine("");
116
+ writeLine(bold(textColors.heading.secondary("Options:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
117
+ createIntrinsic("hbr", {}),
118
+ createComponent(HelpOptionsDisplay, { get options() {
119
+ return options.value;
120
+ } }),
121
+ createComponent(Spacing, {})
122
+ ];
123
+ }
124
+ }),
125
+ createComponent(Show, {
126
+ get when() {
127
+ return Object.keys(command.children).length > 0;
128
+ },
129
+ get children() {
130
+ return [
131
+ memo(() => code`writeLine("");
132
+ writeLine(bold(textColors.heading.secondary("Commands:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
133
+ createIntrinsic("hbr", {}),
134
+ createComponent(HelpCommandsDisplay, { get commands() {
135
+ return command.children;
136
+ } }),
137
+ createComponent(Spacing, {})
138
+ ];
139
+ }
140
+ }),
141
+ createComponent(Show, {
142
+ get when() {
143
+ return isSetString(command.reference);
144
+ },
145
+ get children() {
146
+ return [
147
+ memo(() => code`writeLine("");
148
+ writeLine(textColors.heading.tertiary(\`More information about this command can be found in the reference documentation at \${link("${command.reference}")}\`)${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
149
+ createIntrinsic("hbr", {}),
150
+ createComponent(Spacing, {})
151
+ ];
152
+ }
153
+ })
154
+ ];
155
+ }
156
+ function sortCommands(commands) {
157
+ return Object.values(commands).sort((a, b) => {
158
+ if (a.tags.some((tag) => tag.toLowerCase() === "deprecated") && !b.tags.some((tag) => tag.toLowerCase() === "deprecated")) return 1;
159
+ else if (!a.tags.some((tag) => tag.toLowerCase() === "deprecated") && b.tags.some((tag) => tag.toLowerCase() === "deprecated")) return -1;
160
+ else if (a.tags.some((tag) => tag.toLowerCase() === "experimental") && !b.tags.some((tag) => tag.toLowerCase() === "experimental")) return 1;
161
+ else if (!a.tags.some((tag) => tag.toLowerCase() === "experimental") && b.tags.some((tag) => tag.toLowerCase() === "experimental")) return -1;
162
+ else if (a.tags.some((tag) => tag.toLowerCase() === "utility") && !b.tags.some((tag) => tag.toLowerCase() === "utility")) return 1;
163
+ else if (!a.tags.some((tag) => tag.toLowerCase() === "utility") && b.tags.some((tag) => tag.toLowerCase() === "utility")) return -1;
164
+ return a.name.localeCompare(b.name);
165
+ });
166
+ }
167
+ /**
168
+ * A component that generates the invocation of the `help` function for a command.
169
+ */
170
+ function VirtualCommandHelpDisplay(props) {
171
+ const { options, segments, commands } = props;
172
+ const context = usePowerlines();
173
+ return [
174
+ createIntrinsic("hbr", {}),
175
+ code`writeLine(bold(textColors.heading.secondary("Common Options:")));`,
176
+ createIntrinsic("hbr", {}),
177
+ createComponent(HelpOptionsDisplay, { options }),
178
+ code`writeLine(""); `,
179
+ createComponent(Spacing, {}),
180
+ createComponent(Show, {
181
+ get when() {
182
+ return Object.keys(commands).length > 0;
183
+ },
184
+ get children() {
185
+ return [
186
+ memo(() => code`writeLine(textColors.body.tertiary("The following commands are available through the ${getAppTitle(context, true)} command-line interface:"));
187
+ writeLine(""); `),
188
+ createComponent(Spacing, {}),
189
+ createComponent(For, {
190
+ get each() {
191
+ return sortCommands(commands);
192
+ },
193
+ doubleHardline: true,
194
+ joiner: code`writeLine(""); `,
195
+ ender: code`writeLine(""); `,
196
+ children: (child) => [
197
+ createIntrinsic("hbr", {}),
198
+ memo(() => code`
199
+ writeLine(textColors.heading.primary(${child.icon ? `(isUnicodeSupported ? " ${child.icon} " : "") + ` : ""}\`${child.title} ${child.isVirtual ? "" : "Command"}${child.tags?.length > 0 ? ` - ${child.tags.map((tag) => `\${textColors.tags.${camelCase(tag)} ? textColors.tags.${camelCase(tag)}(inverse(" ${tag} ")) : textColors.tags.$default(inverse(" ${tag} "))}`).join(" ")}` : ""}\`));
13
200
  writeLine("");
14
- writeLine(textColors.body.tertiary(splitText(\`${s(r.description).replace(/\.+$/,``).trim()}.\`)));
15
- writeLine(""); `),t(`hbr`,{}),e(T,{command:r,indent:2,filterGlobalOptions:!0}),t(`hbr`,{})]}),n(()=>a`help(\`Running a specific command with the help flag (via: \${inlineCode("${l(p)} ${d&&d.length>0?` ${d.join(` `)}`:``} <specific command> --help")}) or the help command with the specific command as arguments (via: \${inlineCode("${l(p)} ${d&&d.length>0?` ${d.join(` `)}`:``} help <specific command>")}) will provide additional information that is specific to that command.\`);
16
- writeLine("");`)]}})]}function O(o){let{command:c}=o,u=g();return[a`writeLine(""); `,e(h,{}),e(T,{command:c,filterGlobalOptions:!1}),a`writeLine(""); `,e(h,{}),e(i,{get when(){return Object.keys(c.children).length>0},get children(){return[a`writeLine(textColors.body.tertiary("The following sub-commands are available:"));
17
- writeLine(""); `,e(h,{}),e(r,{get each(){return E(c.children)},doubleHardline:!0,joiner:a`writeLine(""); `,ender:a`writeLine(""); `,children:r=>[t(`hbr`,{}),n(()=>a`
18
- writeLine(textColors.heading.primary(${r.icon?`(isUnicodeSupported ? " ${r.icon} " : "") + `:``}\`${r.title} ${r.isVirtual?``:`Command`}${r.tags?.length>0?` - ${r.tags.map(e=>`\${textColors.tags.${y(e)} ? textColors.tags.${y(e)}(inverse(" ${e} ")) : textColors.tags.$default(inverse(" ${e} "))}`).join(` `)}`:``}\`));
201
+ writeLine(textColors.body.tertiary(splitText(\`${formatDescription(child.description).replace(/\.+$/, "").trim()}.\`)));
202
+ writeLine(""); `),
203
+ createIntrinsic("hbr", {}),
204
+ createComponent(BaseHelpDisplay, {
205
+ command: child,
206
+ indent: 2,
207
+ filterGlobalOptions: true
208
+ }),
209
+ createIntrinsic("hbr", {})
210
+ ]
211
+ }),
212
+ memo(() => code`help(\`Running a specific command with the help flag (via: \${inlineCode("${getAppBin(context)} ${segments && segments.length > 0 ? ` ${segments.join(" ")}` : ""} <specific command> --help")}) or the help command with the specific command as arguments (via: \${inlineCode("${getAppBin(context)} ${segments && segments.length > 0 ? ` ${segments.join(" ")}` : ""} help <specific command>")}) will provide additional information that is specific to that command.\`);
213
+ writeLine("");`)
214
+ ];
215
+ }
216
+ })
217
+ ];
218
+ }
219
+ /**
220
+ * A component that generates the invocation of the `help` function for a command.
221
+ */
222
+ function CommandHelpDisplay(props) {
223
+ const { command } = props;
224
+ const context = usePowerlines();
225
+ return [
226
+ code`writeLine(""); `,
227
+ createComponent(Spacing, {}),
228
+ createComponent(BaseHelpDisplay, {
229
+ command,
230
+ filterGlobalOptions: false
231
+ }),
232
+ code`writeLine(""); `,
233
+ createComponent(Spacing, {}),
234
+ createComponent(Show, {
235
+ get when() {
236
+ return Object.keys(command.children).length > 0;
237
+ },
238
+ get children() {
239
+ return [
240
+ code`writeLine(textColors.body.tertiary("The following sub-commands are available:"));
241
+ writeLine(""); `,
242
+ createComponent(Spacing, {}),
243
+ createComponent(For, {
244
+ get each() {
245
+ return sortCommands(command.children);
246
+ },
247
+ doubleHardline: true,
248
+ joiner: code`writeLine(""); `,
249
+ ender: code`writeLine(""); `,
250
+ children: (child) => [
251
+ createIntrinsic("hbr", {}),
252
+ memo(() => code`
253
+ writeLine(textColors.heading.primary(${child.icon ? `(isUnicodeSupported ? " ${child.icon} " : "") + ` : ""}\`${child.title} ${child.isVirtual ? "" : "Command"}${child.tags?.length > 0 ? ` - ${child.tags.map((tag) => `\${textColors.tags.${camelCase(tag)} ? textColors.tags.${camelCase(tag)}(inverse(" ${tag} ")) : textColors.tags.$default(inverse(" ${tag} "))}`).join(" ")}` : ""}\`));
19
254
  writeLine("");
20
- writeLine(textColors.body.tertiary(splitText(\`${s(r.description).replace(/\.+$/,``).trim()}.\`)));
21
- writeLine(""); `),t(`hbr`,{}),e(T,{command:r,indent:2,filterGlobalOptions:!0}),t(`hbr`,{})]}),n(()=>a`help(\`Running a specific command with the help flag (via: \${inlineCode("${l(u)} ${c.segments.join(` `)} <specific command> --help")}) will provide additional information that is specific to that command.\`);
22
- writeLine("");`)]}})]}export{T as BaseHelpDisplay,O as CommandHelpDisplay,w as HelpCommandsDisplay,C as HelpOptionsDisplay,S as HelpUsageDisplay,D as VirtualCommandHelpDisplay};
255
+ writeLine(textColors.body.tertiary(splitText(\`${formatDescription(child.description).replace(/\.+$/, "").trim()}.\`)));
256
+ writeLine(""); `),
257
+ createIntrinsic("hbr", {}),
258
+ createComponent(BaseHelpDisplay, {
259
+ command: child,
260
+ indent: 2,
261
+ filterGlobalOptions: true
262
+ }),
263
+ createIntrinsic("hbr", {})
264
+ ]
265
+ }),
266
+ memo(() => code`help(\`Running a specific command with the help flag (via: \${inlineCode("${getAppBin(context)} ${command.segments.join(" ")} <specific command> --help")}) will provide additional information that is specific to that command.\`);
267
+ writeLine("");`)
268
+ ];
269
+ }
270
+ })
271
+ ];
272
+ }
273
+
274
+ //#endregion
275
+ export { BaseHelpDisplay, CommandHelpDisplay, HelpCommandsDisplay, HelpOptionsDisplay, HelpUsageDisplay, VirtualCommandHelpDisplay };
23
276
  //# sourceMappingURL=display.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"display.mjs","names":[],"sources":["../../src/components/display.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 { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandOption, CommandTree } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport {\n formatDescription,\n formatShortDescription,\n getAppBin,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n sortOptions\n} from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { HelpPluginContext } from \"../types/plugin\";\n\nexport interface HelpUsageDisplayProps {\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 HelpUsageDisplay(props: HelpUsageDisplayProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n const theme = useTheme();\n\n return (\n <>\n {code`\n writeLine(\n textColors.body.secondary(\\`\\${textColors.usage.bin(\"$_ ${getAppBin(\n context\n )}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${textColors.usage.${\n isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"\n }(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${\n Object.values(command.children).length > 0\n ? ` \\${textColors.usage.dynamic(\"[command]\")}`\n : \"\"\n }${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${textColors.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${textColors.usage.options(\"[options]\")}\\`), { padding: ${\n theme.padding.app * indent\n } }\n );`}\n <hbr />\n <Show when={command.args.length > 0}>\n <hbr />\n {code`\n writeLine(\n textColors.body.secondary(\\`\\${textColors.usage.bin(\"$_ ${getAppBin(context)}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${textColors.usage.${\n isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"\n }(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${\n Object.values(command.children).length > 0\n ? ` \\${textColors.usage.dynamic(\"[command]\")}`\n : \"\"\n } \\${textColors.usage.options(\"[options]\")}${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${textColors.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface HelpOptionsDisplayProps {\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 HelpOptionsDisplay(props: HelpOptionsDisplayProps) {\n const { options } = props;\n\n const context = usePowerlines<HelpPluginContext>();\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: textColors.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === CommandParameterKinds.string\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.format\n ? option.format\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === CommandParameterKinds.number\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\", maxWidth: \"1/3\" }, { value: textColors.body.tertiary(\\`${formatShortDescription(\n option.description,\n {\n length: 200\n }\n )\n .replace(/\\.+$/, \"\")\n .trim()}${\n option.env || option.default !== undefined\n ? ` (${\n option.env\n ? `env: ${context.config.appSpecificEnvPrefix}_${\n option.env\n }${option.default !== undefined ? \", \" : \"\"}`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default).replace(\n /\"/g,\n '\\\\\"'\n )}`\n : \"\"\n })`\n : \"\"\n }.\\`), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsDisplayProps {\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 HelpCommandsDisplay(props: HelpCommandsDisplayProps) {\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: textColors.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: textColors.body.tertiary(\\`${formatShortDescription(\n child.description,\n {\n length: 200\n }\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpDisplayProps {\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 BaseHelpDisplay(props: BaseHelpDisplayProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<HelpPluginContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.globalOptions.some(\n (globalOption: CommandOption) =>\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(bold(textColors.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsageDisplay command={command} indent={indent} />\n <Spacing />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(bold(textColors.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptionsDisplay options={options.value} />\n <Spacing />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(bold(textColors.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommandsDisplay commands={command.children} />\n <Spacing />\n </Show>\n <Show when={isSetString(command.reference)}>\n {code`writeLine(\"\");\n writeLine(textColors.heading.tertiary(\\`More information about this command can be found in the reference documentation at \\${link(\"${\n command.reference\n }\")}\\`)${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <Spacing />\n </Show>\n </>\n );\n}\n\nexport interface VirtualCommandHelpDisplayProps {\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 segments?: string[];\n}\n\nfunction sortCommands(commands: Record<string, CommandTree>) {\n return Object.values(commands).sort((a, b) => {\n if (\n a.tags.some(tag => tag.toLowerCase() === \"deprecated\") &&\n !b.tags.some(tag => tag.toLowerCase() === \"deprecated\")\n ) {\n return 1;\n } else if (\n !a.tags.some(tag => tag.toLowerCase() === \"deprecated\") &&\n b.tags.some(tag => tag.toLowerCase() === \"deprecated\")\n ) {\n return -1;\n } else if (\n a.tags.some(tag => tag.toLowerCase() === \"experimental\") &&\n !b.tags.some(tag => tag.toLowerCase() === \"experimental\")\n ) {\n return 1;\n } else if (\n !a.tags.some(tag => tag.toLowerCase() === \"experimental\") &&\n b.tags.some(tag => tag.toLowerCase() === \"experimental\")\n ) {\n return -1;\n } else if (\n a.tags.some(tag => tag.toLowerCase() === \"utility\") &&\n !b.tags.some(tag => tag.toLowerCase() === \"utility\")\n ) {\n return 1;\n } else if (\n !a.tags.some(tag => tag.toLowerCase() === \"utility\") &&\n b.tags.some(tag => tag.toLowerCase() === \"utility\")\n ) {\n return -1;\n }\n\n return a.name.localeCompare(b.name);\n });\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualCommandHelpDisplay(\n props: VirtualCommandHelpDisplayProps\n) {\n const { options, segments, commands } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(bold(textColors.heading.secondary(\"Common Options:\")));`}\n <hbr />\n <HelpOptionsDisplay options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(textColors.body.tertiary(\"The following commands are available through the ${getAppTitle(\n context,\n true\n )} command-line interface:\"));\n writeLine(\"\"); `}\n <Spacing />\n <For\n each={sortCommands(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n <hbr />\n {code`\n writeLine(textColors.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\\`${child.title} ${child.isVirtual ? \"\" : \"Command\"}${\n child.tags?.length > 0\n ? ` - ${child.tags\n .map(\n tag =>\n `\\${textColors.tags.${camelCase(tag)} ? textColors.tags.${camelCase(tag)}(inverse(\" ${tag} \")) : textColors.tags.$default(inverse(\" ${tag} \"))}`\n )\n .join(\" \")}`\n : \"\"\n }\\`));\n writeLine(\"\");\n writeLine(textColors.body.tertiary(splitText(\\`${formatDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`)));\n writeLine(\"\"); `}\n <hbr />\n <BaseHelpDisplay command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\\`Running a specific command with the help flag (via: \\${inlineCode(\"${getAppBin(\n context\n )} ${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } <specific command> --help\")}) or the help command with the specific command as arguments (via: \\${inlineCode(\"${getAppBin(\n context\n )} ${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } help <specific command>\")}) will provide additional information that is specific to that command.\\`);\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpDisplayProps {\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 CommandHelpDisplay(props: CommandHelpDisplayProps) {\n const { command } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <Spacing />\n <BaseHelpDisplay command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(textColors.body.tertiary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <Spacing />\n <For\n each={sortCommands(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n <hbr />\n {code`\n writeLine(textColors.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\\`${child.title} ${child.isVirtual ? \"\" : \"Command\"}${\n child.tags?.length > 0\n ? ` - ${child.tags\n .map(\n tag =>\n `\\${textColors.tags.${camelCase(tag)} ? textColors.tags.${camelCase(tag)}(inverse(\" ${tag} \")) : textColors.tags.$default(inverse(\" ${tag} \"))}`\n )\n .join(\" \")}`\n : \"\"\n }\\`));\n writeLine(\"\");\n writeLine(textColors.body.tertiary(splitText(\\`${formatDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`)));\n writeLine(\"\"); `}\n <hbr />\n <BaseHelpDisplay command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\\`Running a specific command with the help flag (via: \\${inlineCode(\"${getAppBin(\n context\n )} ${command.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"],"mappings":"23BAgCA,SAAS,EAAwB,EAAM,CACvC,GAAQ,CACR,UACA,SAAS,GACH,EACC,EAAO,GAAmB,OAEjC,MAAO,CAAA,MAAU,CAAA;;kEAEoB,EAAA,EAAA,CAAA,KAAA,EAAA,SAAA,OAAA,EAAA,IAAA,EAAA,SAAA,IAAA,GAAA,uBAAA,EAAA,EAAA,CAAA,UAAA,UAAA,IAAA,EAAA,EAAA,CAAA,IAAA,EAAA,EAAA,EAAA,CAAA,CAAA,GAAA,EAAA,KAAA,CAAA,KAAA,IAAA,GAAA,KAAA,OAAA,OAAA,EAAA,SAAA,CAAA,OAAA,EAAA,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,CAAA,qBAAA,EAAA,EAAA,CAAA,aAAA,EAAA,4CAAA,EAAA,OAAA,CAAA,KAAA,IAAA,GAAA,GAAA;;iEAEmB,EAAA,EAAA,YAAA,CAAA,QAAA,OAAA,GAAA,CAAA,MAAA,CAAA;iCACV,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACX,QAAS,EACT,OAAQ,EACR,oBAAe,GAChB,CAAC,CAAE,EAAkB,MAAO,EAAC,CAAA,CAAA,CAC/B,CAAC,CAAE,MAAa,CAAC,6EAAO,EAAA,EAAA,CAAA,GAAA,EAAA,SAAA,KAAA,IAAA,CAAA;wBACP,CAAC,EAEtB,CAAC,CAAC"}
1
+ {"version":3,"file":"display.mjs","names":[],"sources":["../../src/components/display.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 { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandOption, CommandTree } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport {\n formatDescription,\n formatShortDescription,\n getAppBin,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n sortOptions\n} from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { HelpPluginContext } from \"../types/plugin\";\n\nexport interface HelpUsageDisplayProps {\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 HelpUsageDisplay(props: HelpUsageDisplayProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n const theme = useTheme();\n\n return (\n <>\n {code`\n writeLine(\n textColors.body.secondary(\\`\\${textColors.usage.bin(\"$_ ${getAppBin(\n context\n )}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${textColors.usage.${\n isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"\n }(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${\n Object.values(command.children).length > 0\n ? ` \\${textColors.usage.dynamic(\"[command]\")}`\n : \"\"\n }${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${textColors.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${textColors.usage.options(\"[options]\")}\\`), { padding: ${\n theme.padding.app * indent\n } }\n );`}\n <hbr />\n <Show when={command.args.length > 0}>\n <hbr />\n {code`\n writeLine(\n textColors.body.secondary(\\`\\${textColors.usage.bin(\"$_ ${getAppBin(context)}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${textColors.usage.${\n isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"\n }(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${\n Object.values(command.children).length > 0\n ? ` \\${textColors.usage.dynamic(\"[command]\")}`\n : \"\"\n } \\${textColors.usage.options(\"[options]\")}${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${textColors.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface HelpOptionsDisplayProps {\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 HelpOptionsDisplay(props: HelpOptionsDisplayProps) {\n const { options } = props;\n\n const context = usePowerlines<HelpPluginContext>();\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: textColors.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === CommandParameterKinds.string\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.format\n ? option.format\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === CommandParameterKinds.number\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\", maxWidth: \"1/3\" }, { value: textColors.body.tertiary(\\`${formatShortDescription(\n option.description,\n {\n length: 200\n }\n )\n .replace(/\\.+$/, \"\")\n .trim()}${\n option.env || option.default !== undefined\n ? ` (${\n option.env\n ? `env: ${context.config.appSpecificEnvPrefix}_${\n option.env\n }${option.default !== undefined ? \", \" : \"\"}`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default).replace(\n /\"/g,\n '\\\\\"'\n )}`\n : \"\"\n })`\n : \"\"\n }.\\`), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsDisplayProps {\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 HelpCommandsDisplay(props: HelpCommandsDisplayProps) {\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: textColors.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: textColors.body.tertiary(\\`${formatShortDescription(\n child.description,\n {\n length: 200\n }\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpDisplayProps {\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 BaseHelpDisplay(props: BaseHelpDisplayProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<HelpPluginContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.globalOptions.some(\n (globalOption: CommandOption) =>\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(bold(textColors.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsageDisplay command={command} indent={indent} />\n <Spacing />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(bold(textColors.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptionsDisplay options={options.value} />\n <Spacing />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(bold(textColors.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommandsDisplay commands={command.children} />\n <Spacing />\n </Show>\n <Show when={isSetString(command.reference)}>\n {code`writeLine(\"\");\n writeLine(textColors.heading.tertiary(\\`More information about this command can be found in the reference documentation at \\${link(\"${\n command.reference\n }\")}\\`)${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <Spacing />\n </Show>\n </>\n );\n}\n\nexport interface VirtualCommandHelpDisplayProps {\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 segments?: string[];\n}\n\nfunction sortCommands(commands: Record<string, CommandTree>) {\n return Object.values(commands).sort((a, b) => {\n if (\n a.tags.some(tag => tag.toLowerCase() === \"deprecated\") &&\n !b.tags.some(tag => tag.toLowerCase() === \"deprecated\")\n ) {\n return 1;\n } else if (\n !a.tags.some(tag => tag.toLowerCase() === \"deprecated\") &&\n b.tags.some(tag => tag.toLowerCase() === \"deprecated\")\n ) {\n return -1;\n } else if (\n a.tags.some(tag => tag.toLowerCase() === \"experimental\") &&\n !b.tags.some(tag => tag.toLowerCase() === \"experimental\")\n ) {\n return 1;\n } else if (\n !a.tags.some(tag => tag.toLowerCase() === \"experimental\") &&\n b.tags.some(tag => tag.toLowerCase() === \"experimental\")\n ) {\n return -1;\n } else if (\n a.tags.some(tag => tag.toLowerCase() === \"utility\") &&\n !b.tags.some(tag => tag.toLowerCase() === \"utility\")\n ) {\n return 1;\n } else if (\n !a.tags.some(tag => tag.toLowerCase() === \"utility\") &&\n b.tags.some(tag => tag.toLowerCase() === \"utility\")\n ) {\n return -1;\n }\n\n return a.name.localeCompare(b.name);\n });\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualCommandHelpDisplay(\n props: VirtualCommandHelpDisplayProps\n) {\n const { options, segments, commands } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(bold(textColors.heading.secondary(\"Common Options:\")));`}\n <hbr />\n <HelpOptionsDisplay options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(textColors.body.tertiary(\"The following commands are available through the ${getAppTitle(\n context,\n true\n )} command-line interface:\"));\n writeLine(\"\"); `}\n <Spacing />\n <For\n each={sortCommands(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n <hbr />\n {code`\n writeLine(textColors.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\\`${child.title} ${child.isVirtual ? \"\" : \"Command\"}${\n child.tags?.length > 0\n ? ` - ${child.tags\n .map(\n tag =>\n `\\${textColors.tags.${camelCase(tag)} ? textColors.tags.${camelCase(tag)}(inverse(\" ${tag} \")) : textColors.tags.$default(inverse(\" ${tag} \"))}`\n )\n .join(\" \")}`\n : \"\"\n }\\`));\n writeLine(\"\");\n writeLine(textColors.body.tertiary(splitText(\\`${formatDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`)));\n writeLine(\"\"); `}\n <hbr />\n <BaseHelpDisplay command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\\`Running a specific command with the help flag (via: \\${inlineCode(\"${getAppBin(\n context\n )} ${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } <specific command> --help\")}) or the help command with the specific command as arguments (via: \\${inlineCode(\"${getAppBin(\n context\n )} ${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } help <specific command>\")}) will provide additional information that is specific to that command.\\`);\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpDisplayProps {\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 CommandHelpDisplay(props: CommandHelpDisplayProps) {\n const { command } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <Spacing />\n <BaseHelpDisplay command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(textColors.body.tertiary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <Spacing />\n <For\n each={sortCommands(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n <hbr />\n {code`\n writeLine(textColors.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\\`${child.title} ${child.isVirtual ? \"\" : \"Command\"}${\n child.tags?.length > 0\n ? ` - ${child.tags\n .map(\n tag =>\n `\\${textColors.tags.${camelCase(tag)} ? textColors.tags.${camelCase(tag)}(inverse(\" ${tag} \")) : textColors.tags.$default(inverse(\" ${tag} \"))}`\n )\n .join(\" \")}`\n : \"\"\n }\\`));\n writeLine(\"\");\n writeLine(textColors.body.tertiary(splitText(\\`${formatDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`)));\n writeLine(\"\"); `}\n <hbr />\n <BaseHelpDisplay command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\\`Running a specific command with the help flag (via: \\${inlineCode(\"${getAppBin(\n context\n )} ${command.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"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAS,iBAAwB,OAAM;CACvC,MAAQ,EACR,SACA,SAAS,MACH;CACN,MAAO,UAAO,eAAmB;;AAEjC,QAAO;EAAA,WAAU,IAAA;;kEAEoB,UAAA,QAAA,CAAA,KAAA,QAAA,SAAA,SAAA,IAAA,IAAA,QAAA,SAAA,KAAA,YAAA,uBAAA,qBAAA,QAAA,GAAA,YAAA,UAAA,IAAA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EAAA,CAAA;KAAA,gBAAA,KAAA;MACvC,IAAI,OAAO;AACT,cAAO,aAAY,QAAS,SAAS;;MAEvC,gBAAe;MACf,QAAI,IAAO;MACX,OAAI,IAAA;MACJ,WAAM,UAAQ;OAAA,gBAAA,OAAA,EAAA,CAAA;OAAA,WAAA,IAAA;uDACV,MAAA,OAAA,2BAAA,MAAA,KAAA,gBAAA,GAAA,IAAA,MAAA,MAAA,GAAA,MAAA,YAAA,KAAA,YAAA,MAAA,MAAA,SAAA,IAAA,MAAA,MAAA,KAAA,KAAA,QAAA,sBAAA,UAAA,IAAA,CAAA,qBAAA,UAAA,IAAA,CAAA,aAAA,IAAA,4CAAA,IAAA,OAAA,CAAA,KAAA,IAAA,KAAA,GAAA;;iEAEmB,kBAAA,MAAA,YAAA,CAAA,QAAA,QAAA,GAAA,CAAA,MAAA,CAAA;iCACV;OAAA,gBAAA,OAAA,EAAA,CAAA;OAAA,gBAAA,iBAAA;QACX,SAAS;QACT,QAAQ;QACR,qBAAe;QAChB,CAAC;OAAE,gBAAkB,OAAO,EAAC,CAAA;OAAA;MAC/B,CAAC;KAAE,WAAa,IAAC,6EAAO,UAAA,QAAA,CAAA,GAAA,QAAA,SAAA,KAAA,IAAA,CAAA;wBACP;KAAC;;GAEtB,CAAC;EAAC"}
@@ -1 +1,99 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./display.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@alloy-js/core`),i=require(`@shell-shock/core/plugin-utils`),a=require(`defu`);a=e.__toESM(a);let o=require(`@powerlines/plugin-alloy/core/components/spacing`),s=require(`@powerlines/plugin-alloy/core/contexts/context`),c=require(`@alloy-js/typescript`),l=require(`@powerlines/plugin-alloy/typescript`),u=require(`@powerlines/plugin-alloy/typescript/components/builtin-file`),d=require(`@stryke/path`);function f(e){let[{command:f,children:p},m]=(0,r.splitProps)(e,[`command`,`children`]),h=(0,s.usePowerlines)();return(0,n.createComponent)(u.BuiltinFile,(0,n.mergeProps)({get id(){return(0,d.joinPaths)(`help`,...f.segments.filter(e=>!(0,i.isDynamicPathSegment)(e)))},get description(){return(0,n.memo)(()=>!!f.path)()?`A collection of utility functions that assist in displaying help information for the ${f.title} command.`:`A collection of utility functions that assist in displaying help information for the ${(0,i.getAppTitle)(h,!0)} command-line interface application.`}},m,{get builtinImports(){return(0,a.default)(m.builtinImports??{},{utils:[`isUnicodeSupported`],console:[`splitText`,`writeLine`,`inlineCode`,`textColors`,`inverse`,`bold`,`help`,`table`,`link`]})},get children(){return[(0,n.createComponent)(l.TSDoc,{get heading(){return`Utility functions for displaying help information for the ${f.path?`${f.title} command`:`${(0,i.getAppTitle)(h,!0)} application`}.`},get children(){return(0,n.createComponent)(l.TSDocRemarks,{get children(){return`This module contains utility functions that assist in displaying help information for the ${f.path?`${f.title} command`:`${(0,i.getAppTitle)(h,!0)} application`}. The main function exported by this module is the \`showHelp\` function, which can be used to display help information for the specified command or application. This function can be called from within the command's handler or from any other part of the application where help information needs to be displayed.`}})}}),(0,n.createComponent)(c.FunctionDeclaration,{export:!0,name:`showHelp`,get doc(){return`Display help information for the ${f.path?`${f.title} command`:`${(0,i.getAppTitle)(h,!0)} application`}.`},get children(){return(0,n.createComponent)(r.Show,{get when(){return!f.isVirtual},get fallback(){return(0,n.createComponent)(t.VirtualCommandHelpDisplay,{get options(){return Object.values(f.options)},get commands(){return f.children??{}}})},get children(){return(0,n.createComponent)(t.CommandHelpDisplay,{command:f})}})}}),(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(r.Show,{get when(){return!!p},children:p})]}}))}exports.HelpBuiltin=f;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_components_display = require('./display.cjs');
4
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let _alloy_js_core = require("@alloy-js/core");
6
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
7
+ let defu = require("defu");
8
+ defu = require_runtime.__toESM(defu);
9
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
10
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
11
+ let _alloy_js_typescript = require("@alloy-js/typescript");
12
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
13
+ let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
14
+ let _stryke_path = require("@stryke/path");
15
+
16
+ //#region src/components/help-builtin.tsx
17
+ /**
18
+ * A built-in help module for Shell Shock.
19
+ */
20
+ function HelpBuiltin(props) {
21
+ const [{ command, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["command", "children"]);
22
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
23
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
24
+ get id() {
25
+ return (0, _stryke_path.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)));
26
+ },
27
+ get description() {
28
+ return (0, _alloy_js_core_jsx_runtime.memo)(() => !!command.path)() ? `A collection of utility functions that assist in displaying help information for the ${command.title} command.` : `A collection of utility functions that assist in displaying help information for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application.`;
29
+ }
30
+ }, rest, {
31
+ get builtinImports() {
32
+ return (0, defu.default)(rest.builtinImports ?? {}, {
33
+ utils: ["isUnicodeSupported"],
34
+ console: [
35
+ "splitText",
36
+ "writeLine",
37
+ "inlineCode",
38
+ "textColors",
39
+ "inverse",
40
+ "bold",
41
+ "help",
42
+ "table",
43
+ "link"
44
+ ]
45
+ });
46
+ },
47
+ get children() {
48
+ return [
49
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, {
50
+ get heading() {
51
+ return `Utility functions for displaying help information for the ${command.path ? `${command.title} command` : `${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application`}.`;
52
+ },
53
+ get children() {
54
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDocRemarks, { get children() {
55
+ return `This module contains utility functions that assist in displaying help information for the ${command.path ? `${command.title} command` : `${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application`}. The main function exported by this module is the \`showHelp\` function, which can be used to display help information for the specified command or application. This function can be called from within the command's handler or from any other part of the application where help information needs to be displayed.`;
56
+ } });
57
+ }
58
+ }),
59
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
60
+ "export": true,
61
+ name: "showHelp",
62
+ get doc() {
63
+ return `Display help information for the ${command.path ? `${command.title} command` : `${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application`}.`;
64
+ },
65
+ get children() {
66
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
67
+ get when() {
68
+ return !command.isVirtual;
69
+ },
70
+ get fallback() {
71
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_display.VirtualCommandHelpDisplay, {
72
+ get options() {
73
+ return Object.values(command.options);
74
+ },
75
+ get commands() {
76
+ return command.children ?? {};
77
+ }
78
+ });
79
+ },
80
+ get children() {
81
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_display.CommandHelpDisplay, { command });
82
+ }
83
+ });
84
+ }
85
+ }),
86
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
87
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
88
+ get when() {
89
+ return Boolean(children);
90
+ },
91
+ children
92
+ })
93
+ ];
94
+ }
95
+ }));
96
+ }
97
+
98
+ //#endregion
99
+ exports.HelpBuiltin = HelpBuiltin;