@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.
- package/dist/components/banner-function-declaration.cjs +101 -0
- package/dist/components/banner-function-declaration.cjs.map +1 -0
- package/dist/components/banner-function-declaration.d.cts +35 -0
- package/dist/components/banner-function-declaration.d.cts.map +1 -0
- package/dist/components/banner-function-declaration.d.mts +35 -0
- package/dist/components/banner-function-declaration.d.mts.map +1 -0
- package/dist/components/banner-function-declaration.mjs +99 -0
- package/dist/components/banner-function-declaration.mjs.map +1 -0
- package/dist/components/bin-entry.cjs +1 -1
- package/dist/components/bin-entry.mjs +1 -1
- package/dist/components/command-entry.cjs +43 -27
- package/dist/components/command-entry.cjs.map +1 -1
- package/dist/components/command-entry.d.cts +9 -7
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +9 -7
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +43 -27
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +7 -28
- package/dist/components/command-router.cjs.map +1 -1
- package/dist/components/command-router.mjs +7 -28
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/console-builtin.cjs +2 -58
- package/dist/components/console-builtin.cjs.map +1 -1
- package/dist/components/console-builtin.d.cts +3 -21
- package/dist/components/console-builtin.d.cts.map +1 -1
- package/dist/components/console-builtin.d.mts +3 -21
- package/dist/components/console-builtin.d.mts.map +1 -1
- package/dist/components/console-builtin.mjs +4 -59
- package/dist/components/console-builtin.mjs.map +1 -1
- package/dist/components/help.cjs +133 -10
- package/dist/components/help.cjs.map +1 -1
- package/dist/components/help.d.cts +48 -8
- package/dist/components/help.d.cts.map +1 -1
- package/dist/components/help.d.mts +48 -8
- package/dist/components/help.d.mts.map +1 -1
- package/dist/components/help.mjs +131 -10
- package/dist/components/help.mjs.map +1 -1
- package/dist/components/index.cjs +6 -9
- package/dist/components/index.d.cts +6 -6
- package/dist/components/index.d.mts +6 -6
- package/dist/components/index.mjs +4 -4
- package/dist/components/utils-builtin.cjs +1 -1
- package/dist/components/utils-builtin.d.mts +7 -7
- package/dist/components/utils-builtin.mjs +1 -1
- package/dist/components/virtual-command-entry.cjs +33 -13
- package/dist/components/virtual-command-entry.cjs.map +1 -1
- package/dist/components/virtual-command-entry.d.cts +8 -6
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +8 -6
- package/dist/components/virtual-command-entry.d.mts.map +1 -1
- package/dist/components/virtual-command-entry.mjs +34 -14
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/index.cjs +20 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +21 -49
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +21 -22
- package/dist/components/args-parser-logic.cjs +0 -678
- package/dist/components/args-parser-logic.cjs.map +0 -1
- package/dist/components/args-parser-logic.d.cts +0 -45
- package/dist/components/args-parser-logic.d.cts.map +0 -1
- package/dist/components/args-parser-logic.d.mts +0 -45
- package/dist/components/args-parser-logic.d.mts.map +0 -1
- package/dist/components/args-parser-logic.mjs +0 -672
- package/dist/components/args-parser-logic.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.mjs","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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I;AAAA,WAAEhD,OAAOC,KAAKP,QAAQW,SAAS,CAACU,SAAS;;GAAC,IAAAV,WAAA;AAAA,WAAA;KAAAC,WACjD1B,IAAI;yEAELe,SAAS,IAAI,gBAAgBE,MAAMmB,QAAQC,MAAMtB,OAAM,MAAO,GAAE,IAC9D;KAAAuB,gBAAA,OAAA,EAAA,CAAA;KAAApB,gBAED0C,cAAY,EAAA,IAACC,WAAQ;AAAA,aAAE/C,QAAQW;QAAQ,CAAA;KAAAa,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA;EAAA"}
|
|
1
|
+
{"version":3,"file":"help.mjs","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,UAAUX,eAAoC;CACpD,MAAMY,QAAQN,UAAU;AAExB,QAAAO,gBACGhB,KAAG;EAAA,IAACiB,OAAI;AAAA,UAAEC,OAAOC,KAAKL,QAAQM,OAAOC,IAAI;;EAAEC,UAAQ;EAAAC,WACjDF,QAAG;GAECvB,IAAI;;;GAEoBkB,gBACxBZ,OAAK;IAAMiB;IAAcT;IAAO,CAAA;GAAAY,WAChC1B,IAAI,kBAAkBiB,MAAMU,QAAQC,MAAMb,OAAM;UAClD;GAAAc,gBAAA,OAAA,EAAA,CAAA;GAAA;EAGF,CAAA;;;;;AAeP,SAAgBC,YAAYjB,OAAyB;CACnD,MAAM,EAAEkB,YAAYlB;CAEpB,MAAMG,UAAUX,eAAoC;AAEpD,QAAA;EAEKL,IAAI;EAAU6B,gBAAA,OAAA,EAAA,CAAA;EAAAX,gBAEdhB,KAAG;GAAA,IAACiB,OAAI;AAAA,WAAEX,YAAYuB,QAAQ;;GAAEP,UAAQ;GAAAC,WACtCO,WAAU;IACT,MAAMC,QAAQ,EAAc;IAC5B,MAAMC,QAAQ,EAAc;AAC5B,QAAIF,OAAOG,KAAKC,WAAW,EACzBH,OAAMI,KAAK,IAAIL,OAAOG,OAAO;QAE7BD,OAAMG,KAAK,KAAK5B,UAAUuB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AMX,YAAW;;kBAExD;OAAAjB,gBAAA,OAAA,EAAA,CAAA;OAAAX,gBAEFwC,UAAQ;QAAC5C,SAAS2C;QAAO1C,QAAQ;QAAG4C,qBAAmB;QAAA,CAAA;OAAA9B,gBAAA,OAAA,EAAA,CAAA;OAAA;MAG3D,CAAA;KAAAH,WAEF1B,IAAI,8DAA8DO,UACjES,QACD,CAAA,GAAIF,QAAQqD,KAAKM,SAAShC,KAAK,IAAI,CAAA;wBACrB;KAAA;;GAAA,CAAA;EAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
1
2
|
const require_components_bin_entry = require('./bin-entry.cjs');
|
|
2
|
-
const require_components_args_parser_logic = require('./args-parser-logic.cjs');
|
|
3
3
|
const require_components_help = require('./help.cjs');
|
|
4
4
|
const require_components_command_router = require('./command-router.cjs');
|
|
5
5
|
const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
|
|
@@ -8,12 +8,15 @@ const require_components_console_builtin = require('./console-builtin.cjs');
|
|
|
8
8
|
const require_components_utils_builtin = require('./utils-builtin.cjs');
|
|
9
9
|
|
|
10
10
|
exports.ArgsUtilities = require_components_utils_builtin.ArgsUtilities;
|
|
11
|
-
exports.
|
|
11
|
+
exports.BannerFunctionBodyDeclaration = require_components_banner_function_declaration.BannerFunctionBodyDeclaration;
|
|
12
|
+
exports.BannerFunctionDeclaration = require_components_banner_function_declaration.BannerFunctionDeclaration;
|
|
13
|
+
exports.BaseHelp = require_components_help.BaseHelp;
|
|
12
14
|
exports.BinEntry = require_components_bin_entry.BinEntry;
|
|
13
15
|
exports.ColorSupportUtilities = require_components_utils_builtin.ColorSupportUtilities;
|
|
14
16
|
exports.ColorsDeclaration = require_components_console_builtin.ColorsDeclaration;
|
|
15
17
|
exports.CommandEntry = require_components_command_entry.CommandEntry;
|
|
16
18
|
exports.CommandHandlerDeclaration = require_components_command_entry.CommandHandlerDeclaration;
|
|
19
|
+
exports.CommandHelp = require_components_help.CommandHelp;
|
|
17
20
|
exports.CommandInvocation = require_components_command_entry.CommandInvocation;
|
|
18
21
|
exports.CommandRouter = require_components_command_router.CommandRouter;
|
|
19
22
|
exports.CommandRouterRoute = require_components_command_router.CommandRouterRoute;
|
|
@@ -21,24 +24,18 @@ exports.ConsoleBuiltin = require_components_console_builtin.ConsoleBuiltin;
|
|
|
21
24
|
exports.DividerFunctionDeclaration = require_components_console_builtin.DividerFunctionDeclaration;
|
|
22
25
|
exports.EnvSupportUtilities = require_components_utils_builtin.EnvSupportUtilities;
|
|
23
26
|
exports.ExitFunctionDeclaration = require_components_utils_builtin.ExitFunctionDeclaration;
|
|
24
|
-
exports.Help = require_components_help.Help;
|
|
25
27
|
exports.HelpCommands = require_components_help.HelpCommands;
|
|
26
28
|
exports.HelpOptions = require_components_help.HelpOptions;
|
|
27
29
|
exports.HelpUsage = require_components_help.HelpUsage;
|
|
28
30
|
exports.HyperlinkSupportUtilities = require_components_utils_builtin.HyperlinkSupportUtilities;
|
|
29
31
|
exports.LinkFunctionDeclaration = require_components_console_builtin.LinkFunctionDeclaration;
|
|
30
32
|
exports.MessageFunctionDeclaration = require_components_console_builtin.MessageFunctionDeclaration;
|
|
31
|
-
exports.OptionsInterfaceDeclaration = require_components_args_parser_logic.OptionsInterfaceDeclaration;
|
|
32
|
-
exports.OptionsMember = require_components_args_parser_logic.OptionsMember;
|
|
33
|
-
exports.OptionsMemberParserLogic = require_components_args_parser_logic.OptionsMemberParserLogic;
|
|
34
|
-
exports.OptionsParserLogic = require_components_args_parser_logic.OptionsParserLogic;
|
|
35
|
-
exports.ParamsParserLogic = require_components_args_parser_logic.ParamsParserLogic;
|
|
36
33
|
exports.RunApplication = require_components_bin_entry.RunApplication;
|
|
37
34
|
exports.StripAnsiFunctionDeclaration = require_components_console_builtin.StripAnsiFunctionDeclaration;
|
|
38
35
|
exports.TableFunctionDeclaration = require_components_console_builtin.TableFunctionDeclaration;
|
|
39
36
|
exports.UtilsBuiltin = require_components_utils_builtin.UtilsBuiltin;
|
|
40
|
-
exports.VariablePathsParserLogic = require_components_args_parser_logic.VariablePathsParserLogic;
|
|
41
37
|
exports.VirtualCommandEntry = require_components_virtual_command_entry.VirtualCommandEntry;
|
|
42
38
|
exports.VirtualCommandHandlerDeclaration = require_components_virtual_command_entry.VirtualCommandHandlerDeclaration;
|
|
39
|
+
exports.VirtualHelp = require_components_help.VirtualHelp;
|
|
43
40
|
exports.WrapAnsiFunction = require_components_console_builtin.WrapAnsiFunction;
|
|
44
41
|
exports.WriteLineFunctionDeclaration = require_components_console_builtin.WriteLineFunctionDeclaration;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BannerFunctionBodyDeclaration, BannerFunctionBodyDeclarationProps, BannerFunctionDeclaration, BannerFunctionDeclarationProps } from "./banner-function-declaration.cjs";
|
|
2
2
|
import { BinEntry, BinEntryProps, RunApplication } from "./bin-entry.cjs";
|
|
3
|
-
import { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation } from "./command-entry.cjs";
|
|
3
|
+
import { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation } from "./command-entry.cjs";
|
|
4
4
|
import { CommandRouter, CommandRouterProps, CommandRouterRoute } from "./command-router.cjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ColorsDeclaration, ConsoleBuiltin, DividerFunctionDeclaration, LinkFunctionDeclaration, MessageFunctionDeclaration, MessageFunctionDeclarationProps, StripAnsiFunctionDeclaration, TableFunctionDeclaration, TableFunctionDeclarationProps, WrapAnsiFunction, WriteLineFunctionDeclaration } from "./console-builtin.cjs";
|
|
6
|
+
import { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps } from "./help.cjs";
|
|
7
7
|
import { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, ExitFunctionDeclaration, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps } from "./utils-builtin.cjs";
|
|
8
|
-
import { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration } from "./virtual-command-entry.cjs";
|
|
9
|
-
export { ArgsUtilities, BannerFunctionDeclaration, BannerFunctionDeclarationProps, BinEntry, BinEntryProps, ColorSupportUtilities, ColorsDeclaration, CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation, CommandRouter, CommandRouterProps, CommandRouterRoute, ConsoleBuiltin,
|
|
8
|
+
import { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps } from "./virtual-command-entry.cjs";
|
|
9
|
+
export { ArgsUtilities, BannerFunctionBodyDeclaration, BannerFunctionBodyDeclarationProps, BannerFunctionDeclaration, BannerFunctionDeclarationProps, BaseHelp, BaseHelpProps, BinEntry, BinEntryProps, ColorSupportUtilities, ColorsDeclaration, CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandHelp, CommandHelpProps, CommandInvocation, CommandRouter, CommandRouterProps, CommandRouterRoute, ConsoleBuiltin, DividerFunctionDeclaration, EnvSupportUtilities, ExitFunctionDeclaration, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, HyperlinkSupportUtilities, LinkFunctionDeclaration, MessageFunctionDeclaration, MessageFunctionDeclarationProps, RunApplication, StripAnsiFunctionDeclaration, TableFunctionDeclaration, TableFunctionDeclarationProps, UtilsBuiltin, UtilsBuiltinProps, VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps, VirtualHelp, VirtualHelpProps, WrapAnsiFunction, WriteLineFunctionDeclaration };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BannerFunctionBodyDeclaration, BannerFunctionBodyDeclarationProps, BannerFunctionDeclaration, BannerFunctionDeclarationProps } from "./banner-function-declaration.mjs";
|
|
2
2
|
import { BinEntry, BinEntryProps, RunApplication } from "./bin-entry.mjs";
|
|
3
|
-
import { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation } from "./command-entry.mjs";
|
|
3
|
+
import { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation } from "./command-entry.mjs";
|
|
4
4
|
import { CommandRouter, CommandRouterProps, CommandRouterRoute } from "./command-router.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ColorsDeclaration, ConsoleBuiltin, DividerFunctionDeclaration, LinkFunctionDeclaration, MessageFunctionDeclaration, MessageFunctionDeclarationProps, StripAnsiFunctionDeclaration, TableFunctionDeclaration, TableFunctionDeclarationProps, WrapAnsiFunction, WriteLineFunctionDeclaration } from "./console-builtin.mjs";
|
|
6
|
+
import { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps } from "./help.mjs";
|
|
7
7
|
import { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, ExitFunctionDeclaration, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps } from "./utils-builtin.mjs";
|
|
8
|
-
import { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration } from "./virtual-command-entry.mjs";
|
|
9
|
-
export { ArgsUtilities, BannerFunctionDeclaration, BannerFunctionDeclarationProps, BinEntry, BinEntryProps, ColorSupportUtilities, ColorsDeclaration, CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation, CommandRouter, CommandRouterProps, CommandRouterRoute, ConsoleBuiltin,
|
|
8
|
+
import { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps } from "./virtual-command-entry.mjs";
|
|
9
|
+
export { ArgsUtilities, BannerFunctionBodyDeclaration, BannerFunctionBodyDeclarationProps, BannerFunctionDeclaration, BannerFunctionDeclarationProps, BaseHelp, BaseHelpProps, BinEntry, BinEntryProps, ColorSupportUtilities, ColorsDeclaration, CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandHelp, CommandHelpProps, CommandInvocation, CommandRouter, CommandRouterProps, CommandRouterRoute, ConsoleBuiltin, DividerFunctionDeclaration, EnvSupportUtilities, ExitFunctionDeclaration, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, HyperlinkSupportUtilities, LinkFunctionDeclaration, MessageFunctionDeclaration, MessageFunctionDeclarationProps, RunApplication, StripAnsiFunctionDeclaration, TableFunctionDeclaration, TableFunctionDeclarationProps, UtilsBuiltin, UtilsBuiltinProps, VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps, VirtualHelp, VirtualHelpProps, WrapAnsiFunction, WriteLineFunctionDeclaration };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { BannerFunctionBodyDeclaration, BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
|
|
1
2
|
import { BinEntry, RunApplication } from "./bin-entry.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { Help, HelpCommands, HelpOptions, HelpUsage } from "./help.mjs";
|
|
3
|
+
import { BaseHelp, CommandHelp, HelpCommands, HelpOptions, HelpUsage, VirtualHelp } from "./help.mjs";
|
|
4
4
|
import { CommandRouter, CommandRouterRoute } from "./command-router.mjs";
|
|
5
5
|
import { VirtualCommandEntry, VirtualCommandHandlerDeclaration } from "./virtual-command-entry.mjs";
|
|
6
6
|
import { CommandEntry, CommandHandlerDeclaration, CommandInvocation } from "./command-entry.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { ColorsDeclaration, ConsoleBuiltin, DividerFunctionDeclaration, LinkFunctionDeclaration, MessageFunctionDeclaration, StripAnsiFunctionDeclaration, TableFunctionDeclaration, WrapAnsiFunction, WriteLineFunctionDeclaration } from "./console-builtin.mjs";
|
|
8
8
|
import { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, ExitFunctionDeclaration, HyperlinkSupportUtilities, UtilsBuiltin } from "./utils-builtin.mjs";
|
|
9
9
|
|
|
10
|
-
export { ArgsUtilities, BannerFunctionDeclaration, BinEntry, ColorSupportUtilities, ColorsDeclaration, CommandEntry, CommandHandlerDeclaration, CommandInvocation, CommandRouter, CommandRouterRoute, ConsoleBuiltin, DividerFunctionDeclaration, EnvSupportUtilities, ExitFunctionDeclaration,
|
|
10
|
+
export { ArgsUtilities, BannerFunctionBodyDeclaration, BannerFunctionDeclaration, BaseHelp, BinEntry, ColorSupportUtilities, ColorsDeclaration, CommandEntry, CommandHandlerDeclaration, CommandHelp, CommandInvocation, CommandRouter, CommandRouterRoute, ConsoleBuiltin, DividerFunctionDeclaration, EnvSupportUtilities, ExitFunctionDeclaration, HelpCommands, HelpOptions, HelpUsage, HyperlinkSupportUtilities, LinkFunctionDeclaration, MessageFunctionDeclaration, RunApplication, StripAnsiFunctionDeclaration, TableFunctionDeclaration, UtilsBuiltin, VirtualCommandEntry, VirtualCommandHandlerDeclaration, VirtualHelp, WrapAnsiFunction, WriteLineFunctionDeclaration };
|
|
@@ -2,8 +2,8 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
3
|
let __alloy_js_core = require("@alloy-js/core");
|
|
4
4
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
|
-
let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
|
|
6
5
|
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
6
|
+
let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
|
|
7
7
|
let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
8
8
|
let defu = require("defu");
|
|
9
9
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
3
|
|
|
4
4
|
//#region src/components/utils-builtin.d.ts
|
|
@@ -6,27 +6,27 @@ interface UtilsBuiltinProps extends Omit<BuiltinFileProps, "id" | "description">
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates utilities for detecting terminal color support.
|
|
8
8
|
*/
|
|
9
|
-
declare function EnvSupportUtilities():
|
|
9
|
+
declare function EnvSupportUtilities(): _alloy_js_core0.Children;
|
|
10
10
|
/**
|
|
11
11
|
* Generates utilities for detecting terminal color support.
|
|
12
12
|
*/
|
|
13
|
-
declare function ColorSupportUtilities():
|
|
13
|
+
declare function ColorSupportUtilities(): _alloy_js_core0.Children;
|
|
14
14
|
/**
|
|
15
15
|
* Generates utilities for detecting terminal color support.
|
|
16
16
|
*/
|
|
17
|
-
declare function HyperlinkSupportUtilities():
|
|
17
|
+
declare function HyperlinkSupportUtilities(): _alloy_js_core0.Children;
|
|
18
18
|
/**
|
|
19
19
|
* Generates utilities for detecting terminal color support.
|
|
20
20
|
*/
|
|
21
|
-
declare function ArgsUtilities():
|
|
21
|
+
declare function ArgsUtilities(): _alloy_js_core0.Children;
|
|
22
22
|
/**
|
|
23
23
|
* The `exit` handler function declaration code for the Shell Shock project.
|
|
24
24
|
*/
|
|
25
|
-
declare function ExitFunctionDeclaration():
|
|
25
|
+
declare function ExitFunctionDeclaration(): _alloy_js_core0.Children;
|
|
26
26
|
/**
|
|
27
27
|
* A built-in utilities module for Shell Shock.
|
|
28
28
|
*/
|
|
29
|
-
declare function UtilsBuiltin(props: UtilsBuiltinProps):
|
|
29
|
+
declare function UtilsBuiltin(props: UtilsBuiltinProps): _alloy_js_core0.Children;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, ExitFunctionDeclaration, HyperlinkSupportUtilities, UtilsBuiltin, UtilsBuiltinProps };
|
|
32
32
|
//# sourceMappingURL=utils-builtin.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Show, code, splitProps } from "@alloy-js/core";
|
|
3
3
|
import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
4
|
-
import { getAppTitle } from "@shell-shock/core/plugin-utils/context-helpers";
|
|
5
4
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
5
|
+
import { getAppTitle } from "@shell-shock/core/plugin-utils/context-helpers";
|
|
6
6
|
import { TSDoc, TSDocLink, TSDocParam, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
7
7
|
import defu from "defu";
|
|
8
8
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
2
3
|
const require_components_help = require('./help.cjs');
|
|
3
4
|
const require_components_command_router = require('./command-router.cjs');
|
|
4
5
|
const require_components_command_entry = require('./command-entry.cjs');
|
|
5
6
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
7
|
let __alloy_js_core = require("@alloy-js/core");
|
|
7
8
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
|
-
let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
|
|
9
9
|
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
10
|
+
let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
|
|
10
11
|
let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
12
|
let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
12
13
|
let defu = require("defu");
|
|
@@ -20,11 +21,11 @@ let __powerlines_plugin_alloy_typescript_components_typescript_file = require("@
|
|
|
20
21
|
* A component that generates the `handler` function declaration for a command.
|
|
21
22
|
*/
|
|
22
23
|
function VirtualCommandHandlerDeclaration(props) {
|
|
23
|
-
const { command } = props;
|
|
24
|
+
const { command, children } = props;
|
|
24
25
|
const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
25
26
|
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
26
27
|
get heading() {
|
|
27
|
-
return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.
|
|
28
|
+
return `The ${command.title} (${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.map((segment) => (0, __shell_shock_core_plugin_utils_context_helpers.isPositionalCommandOption)(segment) ? `[${(0, __stryke_string_format_constant_case.constantCase)((0, __shell_shock_core_plugin_utils_context_helpers.getPositionalCommandOptionName)(segment))}]` : segment).join(" ")}) virtual command.`;
|
|
28
29
|
},
|
|
29
30
|
get children() {
|
|
30
31
|
return [
|
|
@@ -52,6 +53,9 @@ function VirtualCommandHandlerDeclaration(props) {
|
|
|
52
53
|
}],
|
|
53
54
|
get children() {
|
|
54
55
|
return [
|
|
56
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
57
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
58
|
+
children,
|
|
55
59
|
(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
|
|
56
60
|
get path() {
|
|
57
61
|
return command.path.segments;
|
|
@@ -62,14 +66,21 @@ function VirtualCommandHandlerDeclaration(props) {
|
|
|
62
66
|
}),
|
|
63
67
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
64
68
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
writeLine(colors.text.heading.primary("${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context)} - ${command.title}"));
|
|
68
|
-
writeLine("");
|
|
69
|
-
writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
|
|
70
|
-
writeLine("");`),
|
|
69
|
+
__alloy_js_core.code`writeLine("");
|
|
70
|
+
banner();`,
|
|
71
71
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
72
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
72
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
73
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.VirtualHelp, {
|
|
74
|
+
get path() {
|
|
75
|
+
return command.path;
|
|
76
|
+
},
|
|
77
|
+
get options() {
|
|
78
|
+
return Object.values(command.options);
|
|
79
|
+
},
|
|
80
|
+
get commands() {
|
|
81
|
+
return command.children ?? {};
|
|
82
|
+
}
|
|
83
|
+
})
|
|
73
84
|
];
|
|
74
85
|
}
|
|
75
86
|
})];
|
|
@@ -80,7 +91,7 @@ function VirtualCommandHandlerDeclaration(props) {
|
|
|
80
91
|
function VirtualCommandEntry(props) {
|
|
81
92
|
const { command, imports, builtinImports, ...rest } = props;
|
|
82
93
|
const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
83
|
-
const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(context.entryPath, command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.
|
|
94
|
+
const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(context.entryPath, command.path.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils_context_helpers.isPositionalCommandOption)(segment)).join("/"), "index.ts"));
|
|
84
95
|
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_typescript_file.TypescriptFile, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
85
96
|
get path() {
|
|
86
97
|
return filePath.value;
|
|
@@ -110,11 +121,20 @@ function VirtualCommandEntry(props) {
|
|
|
110
121
|
"colors",
|
|
111
122
|
"writeLine"
|
|
112
123
|
],
|
|
113
|
-
utils: [
|
|
124
|
+
utils: [
|
|
125
|
+
"getArgs",
|
|
126
|
+
"hasFlag",
|
|
127
|
+
"isMinimal"
|
|
128
|
+
]
|
|
114
129
|
});
|
|
115
130
|
},
|
|
116
131
|
get children() {
|
|
117
|
-
return
|
|
132
|
+
return [
|
|
133
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_banner_function_declaration.BannerFunctionDeclaration, { command }),
|
|
134
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
135
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
136
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(VirtualCommandHandlerDeclaration, { command })
|
|
137
|
+
];
|
|
118
138
|
}
|
|
119
139
|
})), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
120
140
|
get each() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getPositionalCommandOptionName","isPositionalCommandOption","joinPaths","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandEntry","CommandRouter","VirtualHelp","VirtualCommandHandlerDeclaration","props","command","children","context","_$createComponent","heading","title","path","segments","map","segment","join","description","replace","_$createIntrinsic","name","async","parameters","type","default","commands","options","Object","values","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","value","didyoumean2","entries","child","isVirtual","reduce","ret","alias","console","utils","each","when","fallback"],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { VirtualHelp } from \"./help\";\n\nexport interface VirtualCommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(\n props: VirtualCommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <hbr />\n <hbr />\n {children}\n <CommandRouter\n path={command.path.segments}\n commands={command.children}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n <VirtualHelp\n path={command.path}\n options={Object.values(command.options)}\n commands={command.children ?? {}}\n />\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"warn\", \"error\", \"table\", \"colors\", \"writeLine\"],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <VirtualCommandHandlerDeclaration command={command} />\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgBsB,iCACdC,OACA;CACA,MAAM,EAAEC,SAASC,aAAaF;CAE9B,MAAMG,8EAA8C;AAEpD,QAAA,kDAEKpB,6DAAK;EAAA,IACJsB,UAAO;AAAA,UAAE,OAAOJ,QAAQK,MAAK,mEAAeH,QAAQ,CAAA,GAAIF,QAAQM,KAAKC,SAClEC,KAAIC,2FACuBA,QAAQ,GAC9B,+IAAgDA,QAAQ,CAAC,CAAA,KACzDA,QACL,CACAC,KA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|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { CommandTree } from "@shell-shock/core/types/command";
|
|
3
3
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
4
4
|
|
|
5
5
|
//#region src/components/virtual-command-entry.d.ts
|
|
6
|
+
interface VirtualCommandHandlerDeclarationProps {
|
|
7
|
+
command: CommandTree;
|
|
8
|
+
children?: Children;
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* A component that generates the `handler` function declaration for a command.
|
|
8
12
|
*/
|
|
9
|
-
declare function VirtualCommandHandlerDeclaration(props:
|
|
10
|
-
command: CommandTree;
|
|
11
|
-
}): _alloy_js_core5.Children;
|
|
13
|
+
declare function VirtualCommandHandlerDeclaration(props: VirtualCommandHandlerDeclarationProps): Children;
|
|
12
14
|
interface VirtualCommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
|
|
13
15
|
command: CommandTree;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* The virtual command entry point for the Shell Shock project.
|
|
17
19
|
*/
|
|
18
|
-
declare function VirtualCommandEntry(props: VirtualCommandEntryProps):
|
|
20
|
+
declare function VirtualCommandEntry(props: VirtualCommandEntryProps): Children;
|
|
19
21
|
//#endregion
|
|
20
|
-
export { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration };
|
|
22
|
+
export { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps };
|
|
21
23
|
//# sourceMappingURL=virtual-command-entry.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.d.cts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.d.cts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA+CiB,qCAAA;WACN;EADM,QAAA,CAAA,EAEJ,QAFI;AAQjB;AAkDA;;;AAAkD,iBAlDlC,gCAAA,CAkDkC,KAAA,EAjDzC,qCAiDyC,CAAA,EAjDJ,QAiDI;AAAI,UAArC,wBAAA,SAAiC,IAAI,CACpD,cADoD,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAUtC,OAAA,EANL,WAMK;;;;;iBAAA,mBAAA,QAA2B,2BAAwB"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
3
|
import { CommandTree } from "@shell-shock/core/types/command";
|
|
4
4
|
|
|
5
5
|
//#region src/components/virtual-command-entry.d.ts
|
|
6
|
+
interface VirtualCommandHandlerDeclarationProps {
|
|
7
|
+
command: CommandTree;
|
|
8
|
+
children?: Children;
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* A component that generates the `handler` function declaration for a command.
|
|
8
12
|
*/
|
|
9
|
-
declare function VirtualCommandHandlerDeclaration(props:
|
|
10
|
-
command: CommandTree;
|
|
11
|
-
}): _alloy_js_core0.Children;
|
|
13
|
+
declare function VirtualCommandHandlerDeclaration(props: VirtualCommandHandlerDeclarationProps): Children;
|
|
12
14
|
interface VirtualCommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
|
|
13
15
|
command: CommandTree;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* The virtual command entry point for the Shell Shock project.
|
|
17
19
|
*/
|
|
18
|
-
declare function VirtualCommandEntry(props: VirtualCommandEntryProps):
|
|
20
|
+
declare function VirtualCommandEntry(props: VirtualCommandEntryProps): Children;
|
|
19
21
|
//#endregion
|
|
20
|
-
export { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration };
|
|
22
|
+
export { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps };
|
|
21
23
|
//# sourceMappingURL=virtual-command-entry.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.d.mts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.d.mts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA+CiB,qCAAA;WACN;EADM,QAAA,CAAA,EAEJ,QAFI;AAQjB;AAkDA;;;AAAkD,iBAlDlC,gCAAA,CAkDkC,KAAA,EAjDzC,qCAiDyC,CAAA,EAjDJ,QAiDI;AAAI,UAArC,wBAAA,SAAiC,IAAI,CACpD,cADoD,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAUtC,OAAA,EANL,WAMK;;;;;iBAAA,mBAAA,QAA2B,2BAAwB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
|
|
2
|
+
import { VirtualHelp } from "./help.mjs";
|
|
2
3
|
import { CommandRouter } from "./command-router.mjs";
|
|
3
4
|
import { CommandEntry } from "./command-entry.mjs";
|
|
4
5
|
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
6
|
import { For, Show, code, computed } from "@alloy-js/core";
|
|
6
7
|
import { FunctionDeclaration } from "@alloy-js/typescript";
|
|
7
|
-
import { getAppBin, getAppTitle, getVariableCommandPathName, isVariableCommandPath } from "@shell-shock/core/plugin-utils/context-helpers";
|
|
8
8
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
9
|
+
import { getAppBin, getPositionalCommandOptionName, isPositionalCommandOption } from "@shell-shock/core/plugin-utils/context-helpers";
|
|
9
10
|
import { TSDoc, TSDocParam, TSDocRemarks, TSDocTitle } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
10
11
|
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
11
12
|
import defu from "defu";
|
|
@@ -18,11 +19,11 @@ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript/components/t
|
|
|
18
19
|
* A component that generates the `handler` function declaration for a command.
|
|
19
20
|
*/
|
|
20
21
|
function VirtualCommandHandlerDeclaration(props) {
|
|
21
|
-
const { command } = props;
|
|
22
|
+
const { command, children } = props;
|
|
22
23
|
const context = usePowerlines();
|
|
23
24
|
return [createComponent(TSDoc, {
|
|
24
25
|
get heading() {
|
|
25
|
-
return `The ${command.title} (${getAppBin(context)} ${command.path.segments.map((segment) =>
|
|
26
|
+
return `The ${command.title} (${getAppBin(context)} ${command.path.segments.map((segment) => isPositionalCommandOption(segment) ? `[${constantCase(getPositionalCommandOptionName(segment))}]` : segment).join(" ")}) virtual command.`;
|
|
26
27
|
},
|
|
27
28
|
get children() {
|
|
28
29
|
return [
|
|
@@ -50,6 +51,9 @@ function VirtualCommandHandlerDeclaration(props) {
|
|
|
50
51
|
}],
|
|
51
52
|
get children() {
|
|
52
53
|
return [
|
|
54
|
+
createIntrinsic("hbr", {}),
|
|
55
|
+
createIntrinsic("hbr", {}),
|
|
56
|
+
children,
|
|
53
57
|
createComponent(CommandRouter, {
|
|
54
58
|
get path() {
|
|
55
59
|
return command.path.segments;
|
|
@@ -60,14 +64,21 @@ function VirtualCommandHandlerDeclaration(props) {
|
|
|
60
64
|
}),
|
|
61
65
|
createIntrinsic("hbr", {}),
|
|
62
66
|
createIntrinsic("hbr", {}),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
writeLine(colors.text.heading.primary("${getAppTitle(context)} - ${command.title}"));
|
|
66
|
-
writeLine("");
|
|
67
|
-
writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
|
|
68
|
-
writeLine("");`),
|
|
67
|
+
code`writeLine("");
|
|
68
|
+
banner();`,
|
|
69
69
|
createIntrinsic("hbr", {}),
|
|
70
|
-
|
|
70
|
+
createIntrinsic("hbr", {}),
|
|
71
|
+
createComponent(VirtualHelp, {
|
|
72
|
+
get path() {
|
|
73
|
+
return command.path;
|
|
74
|
+
},
|
|
75
|
+
get options() {
|
|
76
|
+
return Object.values(command.options);
|
|
77
|
+
},
|
|
78
|
+
get commands() {
|
|
79
|
+
return command.children ?? {};
|
|
80
|
+
}
|
|
81
|
+
})
|
|
71
82
|
];
|
|
72
83
|
}
|
|
73
84
|
})];
|
|
@@ -78,7 +89,7 @@ function VirtualCommandHandlerDeclaration(props) {
|
|
|
78
89
|
function VirtualCommandEntry(props) {
|
|
79
90
|
const { command, imports, builtinImports, ...rest } = props;
|
|
80
91
|
const context = usePowerlines();
|
|
81
|
-
const filePath = computed(() => joinPaths(context.entryPath, command.path.segments.filter((segment) => !
|
|
92
|
+
const filePath = computed(() => joinPaths(context.entryPath, command.path.segments.filter((segment) => !isPositionalCommandOption(segment)).join("/"), "index.ts"));
|
|
82
93
|
return [createComponent(TypescriptFile, mergeProps(rest, {
|
|
83
94
|
get path() {
|
|
84
95
|
return filePath.value;
|
|
@@ -108,11 +119,20 @@ function VirtualCommandEntry(props) {
|
|
|
108
119
|
"colors",
|
|
109
120
|
"writeLine"
|
|
110
121
|
],
|
|
111
|
-
utils: [
|
|
122
|
+
utils: [
|
|
123
|
+
"getArgs",
|
|
124
|
+
"hasFlag",
|
|
125
|
+
"isMinimal"
|
|
126
|
+
]
|
|
112
127
|
});
|
|
113
128
|
},
|
|
114
129
|
get children() {
|
|
115
|
-
return
|
|
130
|
+
return [
|
|
131
|
+
createComponent(BannerFunctionDeclaration, { command }),
|
|
132
|
+
createIntrinsic("hbr", {}),
|
|
133
|
+
createIntrinsic("hbr", {}),
|
|
134
|
+
createComponent(VirtualCommandHandlerDeclaration, { command })
|
|
135
|
+
];
|
|
116
136
|
}
|
|
117
137
|
})), createComponent(For, {
|
|
118
138
|
get each() {
|