@shell-shock/preset-script 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/components/banner-function-declaration.cjs +53 -20
  2. package/dist/components/banner-function-declaration.cjs.map +1 -1
  3. package/dist/components/banner-function-declaration.d.cts +20 -4
  4. package/dist/components/banner-function-declaration.d.cts.map +1 -1
  5. package/dist/components/banner-function-declaration.d.mts +20 -4
  6. package/dist/components/banner-function-declaration.d.mts.map +1 -1
  7. package/dist/components/banner-function-declaration.mjs +54 -22
  8. package/dist/components/banner-function-declaration.mjs.map +1 -1
  9. package/dist/components/command-entry.cjs +18 -12
  10. package/dist/components/command-entry.cjs.map +1 -1
  11. package/dist/components/command-entry.d.cts +10 -8
  12. package/dist/components/command-entry.d.cts.map +1 -1
  13. package/dist/components/command-entry.d.mts +9 -7
  14. package/dist/components/command-entry.d.mts.map +1 -1
  15. package/dist/components/command-entry.mjs +20 -14
  16. package/dist/components/command-entry.mjs.map +1 -1
  17. package/dist/components/command-router.cjs +1 -1
  18. package/dist/components/command-router.mjs +1 -1
  19. package/dist/components/help.cjs +70 -13
  20. package/dist/components/help.cjs.map +1 -1
  21. package/dist/components/help.d.cts +36 -10
  22. package/dist/components/help.d.cts.map +1 -1
  23. package/dist/components/help.d.mts +36 -10
  24. package/dist/components/help.d.mts.map +1 -1
  25. package/dist/components/help.mjs +68 -12
  26. package/dist/components/help.mjs.map +1 -1
  27. package/dist/components/index.cjs +4 -2
  28. package/dist/components/index.d.cts +5 -5
  29. package/dist/components/index.d.mts +5 -5
  30. package/dist/components/index.mjs +3 -3
  31. package/dist/components/virtual-command-entry.cjs +30 -10
  32. package/dist/components/virtual-command-entry.cjs.map +1 -1
  33. package/dist/components/virtual-command-entry.d.cts +9 -7
  34. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  35. package/dist/components/virtual-command-entry.d.mts +8 -6
  36. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  37. package/dist/components/virtual-command-entry.mjs +32 -12
  38. package/dist/components/virtual-command-entry.mjs.map +1 -1
  39. package/dist/index.cjs +6 -1
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts.map +1 -1
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +7 -2
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/types/plugin.d.mts.map +1 -1
  46. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","OptionsInterfaceDeclaration","OptionsParserLogic","PositionalOptionsParserLogic","getAppBin","getAppTitle","getPositionalCommandOptionName","isPositionalCommandOption","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","Help","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","context","_$createComponent","heading","title","children","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n PositionalOptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getAppTitle,\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { Help } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).length > 0\n ? `, ${command.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .map(segment =>\n camelCase(getPositionalCommandOptionName(segment))\n )\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <PositionalOptionsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(\n /\\.+$/,\n \"\"\n )}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"isMinimal\"]\n })}>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,6CAEK/B,oBAAI,mFAA2CgC,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,2FACDA,QAC5B,CAAC,CAACC,SAAS,IACP,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,2FAAqCA,QAAQ,CAAC,CACrDE,KAAIF,iJACsCA,QAAQ,CACnD,CAAC,CACAG,KAAK,KAAK,KACb,GAAE,KACH,mDAAA,OAAA,EAAA,CAAA,CAAA;;;;;AASX,SAAgBE,0BAA0BZ,OAAiC;CACzE,MAAM,EAAEC,YAAYD;CAEpB,MAAMa,8EAA8C;AAEpD,QAAA,kDAEKnC,6DAAK;EAAA,IACJqC,UAAO;AAAA,UAAE,OAAOd,QAAQe,MAAK,mEAC3BH,QACD,CAAA,GAAIZ,QAAQG,KAAKC,SACfI,KAAIF,2FACuBA,QAAQ,GAC9B,+IAAgDA,QAAQ,CAAC,CAAA,KACzDA,QACL,CACAG,KAAK,IAAI,CAAA;;EA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ME;;GAAS,IACrBC,WAAQ;AAAA,4DAAGxB,cAAY,EAAC3B,SAASgD,OAAK,CAAA;;GAAA,IAAAhC,WAAA;AAAA,4DACrCnB,8DAAmB,EAACG,SAASgD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.cjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","OptionsInterfaceDeclaration","OptionsParserLogic","PositionalOptionsParserLogic","getAppBin","getPositionalCommandOptionName","isPositionalCommandOption","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandHelp","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","children","context","_$createComponent","heading","title","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n PositionalOptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\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 { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandHelp } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).length > 0\n ? `, ${command.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .map(segment =>\n camelCase(getPositionalCommandOptionName(segment))\n )\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <PositionalOptionsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n <CommandHelp command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,6CAEK/B,oBAAI,mFAA2CgC,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,2FACDA,QAC5B,CAAC,CAACC,SAAS,IACP,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,2FAAqCA,QAAQ,CAAC,CACrDE,KAAIF,iJACsCA,QAAQ,CACnD,CAAC,CACAG,KAAK,KAAK,KACb,GAAE,KACH,mDAAA,OAAA,EAAA,CAAA,CAAA;;;;;AAcX,SAAgBE,0BACdZ,OACA;CACA,MAAM,EAAEC,SAASY,aAAab;CAE9B,MAAMc,8EAA8C;AAEpD,QAAA,kDAEKpC,6DAAK;EAAA,IACJsC,UAAO;AAAA,UAAE,OAAOf,QAAQgB,MAAK,mEAC3BH,QACD,CAAA,GAAIb,QAAQG,KAAKC,SACfI,KAAIF,2FACuBA,QAAQ,GAC9B,+IAAgDA,QAAQ,CAAC,CAAA,KACzDA,QACL,CACAG,KAAK,IAAI,CAAA;;EAAY,IAAAG,WAAA;AAAA,UAAA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I;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,4DAAGxB,cAAY,EAAC3B,SAASgD,OAAK,CAAA;;GAAA,IAAApC,WAAA;AAAA,4DACrCf,8DAAmB,EAACG,SAASgD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -1,24 +1,26 @@
1
- import * as _alloy_js_core13 from "@alloy-js/core";
2
- import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
1
+ import { Children } from "@alloy-js/core";
3
2
  import { CommandTree } from "@shell-shock/core/types/command";
3
+ import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
4
4
 
5
5
  //#region src/components/command-entry.d.ts
6
6
  declare function CommandInvocation(props: {
7
7
  command: CommandTree;
8
- }): _alloy_js_core13.Children;
8
+ }): Children;
9
+ interface CommandHandlerDeclarationProps {
10
+ command: CommandTree;
11
+ children?: Children;
12
+ }
9
13
  /**
10
14
  * A component that generates the `handler` function declaration for a command.
11
15
  */
12
- declare function CommandHandlerDeclaration(props: {
13
- command: CommandTree;
14
- }): _alloy_js_core13.Children;
16
+ declare function CommandHandlerDeclaration(props: CommandHandlerDeclarationProps): Children;
15
17
  interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
18
  command: CommandTree;
17
19
  }
18
20
  /**
19
21
  * The command entry point for the Shell Shock project.
20
22
  */
21
- declare function CommandEntry(props: CommandEntryProps): _alloy_js_core13.Children;
23
+ declare function CommandEntry(props: CommandEntryProps): Children;
22
24
  //#endregion
23
- export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
25
+ export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation };
24
26
  //# sourceMappingURL=command-entry.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAwDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AAyBA;AAgEA;AACE,iBAjEc,yBAAA,CAiEd,KAAA,EAAA;EAGS,OAAA,EApEiD,WAoEjD;CAJgC,CAAA,EAhE4B,gBAAA,CAAE,QAgE9B;AAAI,UAA9B,iBAAA,SAA0B,IAAI,CAC7C,cAD6C,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAU/B,OAAA,EANL,WAMiB;;;;;iBAAZ,YAAA,QAAoB,oBAAiB,gBAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AAsBC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EA6DC,QAAA,CAAA,EAnEJ,QAmEI;;;;;AAUD,iBAvEA,yBAAA,CAuEqC,KAAA,EAtE5C,8BAsE4C,CAAA,EAtEd,QAsEc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
@@ -1,24 +1,26 @@
1
- import * as _alloy_js_core12 from "@alloy-js/core";
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/command-entry.d.ts
6
6
  declare function CommandInvocation(props: {
7
7
  command: CommandTree;
8
- }): _alloy_js_core12.Children;
8
+ }): Children;
9
+ interface CommandHandlerDeclarationProps {
10
+ command: CommandTree;
11
+ children?: Children;
12
+ }
9
13
  /**
10
14
  * A component that generates the `handler` function declaration for a command.
11
15
  */
12
- declare function CommandHandlerDeclaration(props: {
13
- command: CommandTree;
14
- }): _alloy_js_core12.Children;
16
+ declare function CommandHandlerDeclaration(props: CommandHandlerDeclarationProps): Children;
15
17
  interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
16
18
  command: CommandTree;
17
19
  }
18
20
  /**
19
21
  * The command entry point for the Shell Shock project.
20
22
  */
21
- declare function CommandEntry(props: CommandEntryProps): _alloy_js_core12.Children;
23
+ declare function CommandEntry(props: CommandEntryProps): Children;
22
24
  //#endregion
23
- export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandInvocation };
25
+ export { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation };
24
26
  //# sourceMappingURL=command-entry.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAwDgB,iBAAA;WAAoC;IAAW,gBAAA,CAAE;AAAjE;AAyBA;AAgEA;AACE,iBAjEc,yBAAA,CAiEd,KAAA,EAAA;EAGS,OAAA,EApEiD,WAoEjD;CAJgC,CAAA,EAhE4B,gBAAA,CAAE,QAgE9B;AAAI,UAA9B,iBAAA,SAA0B,IAAI,CAC7C,cAD6C,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAU/B,OAAA,EANL,WAMiB;;;;;iBAAZ,YAAA,QAAoB,oBAAiB,gBAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;iBAyDgB,iBAAA;WAAoC;AAApD,CAAA,CAAA,EAAiE,QAAjD;AAsBC,UAAA,8BAAA,CAA8B;EAQ/B,OAAA,EAPL,WAOK;EA6DC,QAAA,CAAA,EAnEJ,QAmEI;;;;;AAUD,iBAvEA,yBAAA,CAuEqC,KAAA,EAtE5C,8BAsE4C,CAAA,EAtEd,QAsEc;UAVpC,iBAAA,SAA0B,KACzC;WAGS;;;;;iBAMK,YAAA,QAAoB,oBAAiB"}
@@ -1,10 +1,11 @@
1
- import { Help } from "./help.mjs";
1
+ import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
+ import { CommandHelp } from "./help.mjs";
2
3
  import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
3
4
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
5
  import { For, Show, code, computed } from "@alloy-js/core";
5
6
  import { ElseClause, FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
6
7
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
- import { getAppBin, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption } from "@shell-shock/core/plugin-utils/context-helpers";
8
+ import { getAppBin, getPositionalCommandOptionName, isPositionalCommandOption } from "@shell-shock/core/plugin-utils/context-helpers";
8
9
  import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
9
10
  import { TSDoc, TSDocParam, TSDocRemarks, TSDocTitle } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
11
  import { replaceExtension } from "@stryke/path/replace";
@@ -25,7 +26,7 @@ function CommandInvocation(props) {
25
26
  * A component that generates the `handler` function declaration for a command.
26
27
  */
27
28
  function CommandHandlerDeclaration(props) {
28
- const { command } = props;
29
+ const { command, children } = props;
29
30
  const context = usePowerlines();
30
31
  return [createComponent(TSDoc, {
31
32
  get heading() {
@@ -78,19 +79,17 @@ function CommandHandlerDeclaration(props) {
78
79
  }),
79
80
  createIntrinsic("hbr", {}),
80
81
  createIntrinsic("hbr", {}),
82
+ code`writeLine("");
83
+ banner();`,
84
+ createIntrinsic("hbr", {}),
85
+ createIntrinsic("hbr", {}),
86
+ children,
87
+ createIntrinsic("hbr", {}),
88
+ createIntrinsic("hbr", {}),
81
89
  createComponent(IfStatement, {
82
90
  condition: code`options.help`,
83
91
  get children() {
84
- return [
85
- memo(() => code`
86
- writeLine("");
87
- writeLine(colors.text.heading.primary("${getAppTitle(context)} - ${command.title}"));
88
- writeLine("");
89
- writeLine(colors.text.body.primary("${command.description.replace(/\.+$/, "")}."));
90
- writeLine("");`),
91
- createIntrinsic("hbr", {}),
92
- createComponent(Help, { command })
93
- ];
92
+ return createComponent(CommandHelp, { command });
94
93
  }
95
94
  }),
96
95
  createComponent(ElseClause, { get children() {
@@ -134,11 +133,18 @@ function CommandEntry(props) {
134
133
  "writeLine",
135
134
  "splitText"
136
135
  ],
137
- utils: ["getArgs", "isMinimal"]
136
+ utils: [
137
+ "getArgs",
138
+ "hasFlag",
139
+ "isMinimal"
140
+ ]
138
141
  });
139
142
  },
140
143
  get children() {
141
144
  return [
145
+ createComponent(BannerFunctionDeclaration, { command }),
146
+ createIntrinsic("hbr", {}),
147
+ createIntrinsic("hbr", {}),
142
148
  createComponent(OptionsInterfaceDeclaration, { command }),
143
149
  createIntrinsic("hbr", {}),
144
150
  createIntrinsic("hbr", {}),
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","OptionsInterfaceDeclaration","OptionsParserLogic","PositionalOptionsParserLogic","getAppBin","getAppTitle","getPositionalCommandOptionName","isPositionalCommandOption","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","Help","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","context","_$createComponent","heading","title","children","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n PositionalOptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getAppTitle,\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { Help } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).length > 0\n ? `, ${command.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .map(segment =>\n camelCase(getPositionalCommandOptionName(segment))\n )\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <PositionalOptionsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n {code`\n writeLine(\"\");\n writeLine(colors.text.heading.primary(\"${getAppTitle(context)} - ${\n command.title\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.primary(\"${command.description.replace(\n /\\.+$/,\n \"\"\n )}.\"));\n writeLine(\"\");`}\n <hbr />\n <Help command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"isMinimal\"]\n })}>\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,CAAAE,WAEKjC,IAAI,gCAAgC0B,WAAWM,QAAQE,KAAK,CAAA,UAC3DF,QAAQG,KAAKC,SAASC,QAAOC,YAC3BnB,0BAA0BmB,QAC5B,CAAC,CAACC,SAAS,IACP,KAAKP,QAAQG,KAAKC,SACfC,QAAOC,YAAWnB,0BAA0BmB,QAAQ,CAAC,CACrDE,KAAIF,YACHd,UAAUN,+BAA+BoB,QAAQ,CACnD,CAAC,CACAG,KAAK,KAAK,KACb,GAAE,KACH,EAAAC,gBAAA,OAAA,EAAA,CAAA,CAAA;;;;;AASX,SAAgBC,0BAA0BZ,OAAiC;CACzE,MAAM,EAAEC,YAAYD;CAEpB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,CAAC;;EAAA,IACF2B,iBAAc;AAAA,UAAElC,KAAKkC,kBAAkB,EAAE,EAAE;IACzCa,KAAK,CAAC,OAAO,OAAO;IACpBC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO,CAAC,WAAW,YAAW;IAC/B,CAAC;;EAAA,IAAA5B,WAAA;AAAA,UAAA;IAAAH,gBACDhC,6BAA2B,EAAUmB,SAAO,CAAA;IAAAU,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAG,gBAG5CF,2BAAyB,EAAUX,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAa,gBAE5C3C,KAAG;EAAA,IAAC2E,OAAI;AAAA,UAAEC,OAAOC,OAAO/C,QAAQgB,SAAS;;EAAAA,WACvCgC,UAAKnC,gBACH1C,MAAI;GAAA,IACH8E,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,WAAAtC,gBAAGc,cAAY,EAAC3B,SAASgD,OAAK,CAAA;;GAAA,IAAAhC,WAAA;AAAA,WAAAH,gBACrChB,qBAAmB,EAACG,SAASgD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Show","ElseClause","FunctionDeclaration","IfStatement","usePowerlines","EntryFile","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","OptionsInterfaceDeclaration","OptionsParserLogic","PositionalOptionsParserLogic","getAppBin","getPositionalCommandOptionName","isPositionalCommandOption","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandHelp","VirtualCommandEntry","CommandInvocation","props","command","_$memo","name","path","segments","filter","segment","length","map","join","_$createIntrinsic","CommandHandlerDeclaration","children","context","_$createComponent","heading","title","description","replace","async","parameters","type","default","envPrefix","config","isCaseSensitive","condition","CommandEntry","imports","builtinImports","rest","filePath","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$mergeProps","env","console","utils","each","Object","values","child","when","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n OptionsInterfaceDeclaration,\n OptionsParserLogic,\n PositionalOptionsParserLogic\n} from \"@shell-shock/core/components/options-parser-logic\";\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 { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandHelp } from \"./help\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n {code`return Promise.resolve(handle${pascalCase(command.name)}(options${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).length > 0\n ? `, ${command.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .map(segment =>\n camelCase(getPositionalCommandOptionName(segment))\n )\n .join(\", \")}`\n : \"\"\n }));`}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(\n context\n )} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `[${constantCase(getPositionalCommandOptionName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <PositionalOptionsParserLogic\n path={command.path}\n envPrefix={context.config.envPrefix}\n />\n <hbr />\n <hbr />\n <OptionsParserLogic\n command={command}\n envPrefix={context.config.envPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n <IfStatement condition={code`options.help`}>\n <CommandHelp command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.path.segments\n .filter(segment => !isPositionalCommandOption(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\"],\n console: [\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <OptionsInterfaceDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command} />\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB8B,kBAAkBC,OAAiC;CACjE,MAAM,EAAEC,YAAYD;AAEpB,QAAA,CAAAE,WAEKjC,IAAI,gCAAgCyB,WAAWO,QAAQ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+3,10 @@ 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
5
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
6
- let __shell_shock_core_contexts_command = require("@shell-shock/core/contexts/command");
7
6
  let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
8
7
  let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
9
8
  let __powerlines_plugin_alloy_typescript_components_dynamic_import_statement = require("@powerlines/plugin-alloy/typescript/components/dynamic-import-statement");
9
+ let __shell_shock_core_contexts_command = require("@shell-shock/core/contexts/command");
10
10
 
11
11
  //#region src/components/command-router.tsx
12
12
  function CommandRouterRoute() {
@@ -2,10 +2,10 @@ import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runti
2
2
  import { For, Show, code, computed } from "@alloy-js/core";
3
3
  import { ElseIfClause, IfStatement, VarDeclaration } from "@alloy-js/typescript";
4
4
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
5
- import { CommandContext, useCommand } from "@shell-shock/core/contexts/command";
6
5
  import { isPositionalCommandOption } from "@shell-shock/core/plugin-utils/context-helpers";
7
6
  import { pascalCase } from "@stryke/string-format/pascal-case";
8
7
  import { DynamicImportStatement } from "@powerlines/plugin-alloy/typescript/components/dynamic-import-statement";
8
+ import { CommandContext, useCommand } from "@shell-shock/core/contexts/command";
9
9
 
10
10
  //#region src/components/command-router.tsx
11
11
  function CommandRouterRoute() {
@@ -90,11 +90,11 @@ function HelpCommands(props) {
90
90
  /**
91
91
  * A component that generates the `help` function declaration for a command.
92
92
  */
93
- function Help(props) {
94
- const { command, indent = 1 } = props;
93
+ function BaseHelp(props) {
94
+ const { command, indent = 1, filterGlobalOptions = false } = props;
95
95
  const theme = require_contexts_theme.useTheme();
96
96
  const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
97
- const options = (0, __alloy_js_core.computed)(() => Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) ?? []);
97
+ const options = (0, __alloy_js_core.computed)(() => filterGlobalOptions ? Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) : Object.values(command.options));
98
98
  return [
99
99
  (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`writeLine(colors.bold(colors.text.heading.secondary("Usage:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
100
100
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
@@ -143,13 +143,11 @@ function Help(props) {
143
143
  /**
144
144
  * A component that generates the invocation of the `help` function for a command.
145
145
  */
146
- function HelpInvoke(props) {
147
- const { options, commands } = props;
146
+ function VirtualHelp(props) {
147
+ const { options, path, commands } = props;
148
148
  const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
149
149
  return [
150
150
  __alloy_js_core.code`
151
- writeLine("");
152
- banner();
153
151
  writeLine(""); `,
154
152
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
155
153
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
@@ -184,15 +182,73 @@ function HelpInvoke(props) {
184
182
  writeLine("");
185
183
  `),
186
184
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
187
- (0, __alloy_js_core_jsx_runtime.createComponent)(Help, {
185
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BaseHelp, {
188
186
  command: child,
189
- indent: 2
187
+ indent: 2,
188
+ filterGlobalOptions: true
190
189
  }),
191
190
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
192
191
  ]
193
192
  }),
194
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} <specific command> --help') will provide additional information that is specific to that command.");
195
- writeLine("");`)
193
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)}${path?.segments && path.segments.length > 0 ? ` ${path.segments.join(" ")}` : ""} <specific command> --help') will provide additional information that is specific to that command.");
194
+ writeLine("");`)
195
+ ];
196
+ }
197
+ })
198
+ ];
199
+ }
200
+ /**
201
+ * A component that generates the invocation of the `help` function for a command.
202
+ */
203
+ function CommandHelp(props) {
204
+ const { command } = props;
205
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
206
+ return [
207
+ __alloy_js_core.code`writeLine(""); `,
208
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
209
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
210
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BaseHelp, {
211
+ command,
212
+ filterGlobalOptions: false
213
+ }),
214
+ __alloy_js_core.code`writeLine(""); `,
215
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
216
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
217
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
218
+ get when() {
219
+ return Object.keys(command.children).length > 0;
220
+ },
221
+ get children() {
222
+ return [
223
+ __alloy_js_core.code`writeLine(colors.text.body.secondary("The following sub-commands are available:"));
224
+ writeLine(""); `,
225
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
226
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
227
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
228
+ get each() {
229
+ return Object.values(command.children);
230
+ },
231
+ doubleHardline: true,
232
+ joiner: __alloy_js_core.code`writeLine(""); `,
233
+ ender: __alloy_js_core.code`writeLine(""); `,
234
+ children: (child) => [
235
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
236
+ writeLine(colors.text.heading.primary("${child.title} ${child.isVirtual ? "" : "Command"}"));
237
+ writeLine("");
238
+ writeLine(colors.text.body.secondary("${child.description}"));
239
+ writeLine("");
240
+ `),
241
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
242
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BaseHelp, {
243
+ command: child,
244
+ indent: 2,
245
+ filterGlobalOptions: true
246
+ }),
247
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
248
+ ]
249
+ }),
250
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0, __shell_shock_core_plugin_utils_context_helpers.getAppBin)(context)} ${command.path.segments.join(" ")} <specific command> --help') will provide additional information that is specific to that command.");
251
+ writeLine("");`)
196
252
  ];
197
253
  }
198
254
  })
@@ -200,9 +256,10 @@ function HelpInvoke(props) {
200
256
  }
201
257
 
202
258
  //#endregion
203
- exports.Help = Help;
259
+ exports.BaseHelp = BaseHelp;
260
+ exports.CommandHelp = CommandHelp;
204
261
  exports.HelpCommands = HelpCommands;
205
- exports.HelpInvoke = HelpInvoke;
206
262
  exports.HelpOptions = HelpOptions;
207
263
  exports.HelpUsage = HelpUsage;
264
+ exports.VirtualHelp = VirtualHelp;
208
265
  //# sourceMappingURL=help.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","usePowerlines","Usage","getAppBin","sortOptions","kebabCase","snakeCase","useTheme","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","padding","app","_$createIntrinsic","HelpOptions","options","option","flags","names","name","length","push","alias","forEach","sort","join","kind","string","variadic","number","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","values","child","Help","filter","some","globalOption","includes","when","value","HelpInvoke","doubleHardline","joiner","ender","title","isVirtual"],"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} 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 HelpProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function Help(props: HelpProps) {\n const { command, indent = 1 } = props;\n\n const theme = useTheme();\n const context = usePowerlines<ScriptPresetContext>();\n\n const options = computed(\n () =>\n Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n ) ?? []\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsage command={command} indent={indent} />\n <hbr />\n <hbr />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptions options={options.value} />\n <hbr />\n <hbr />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommands commands={command.children} />\n <hbr />\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface HelpInvokeProps {\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/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function HelpInvoke(props: HelpInvokeProps) {\n const { options, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`\n writeLine(\"\");\n banner();\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 <Help command={child} indent={2} />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqDA,SAAgBY,UAAUC,OAAuB;CAC/C,MAAM,EAAEC,SAASC,SAAS,MAAMF;CAEhC,MAAMG,8EAA8C;CACpD,MAAMC,QAAQN,iCAAU;AAExB,yDACGT,qBAAG;EAAA,IAACiB,OAAI;AAAA,UAAEC,OAAOC,KAAKL,QAAQM,OAAOC,IAAI;;EAAEC,UAAQ;EAAAC,WAC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A;AAAA,WAAA;KACzCzB,oBAAI;;sDACW,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAGfE,qBAAG;MAAA,IACFiB,OAAI;AAAA,cAAEC,OAAOoC,OAAOD,SAAS;;MAC7BW,gBAAc;MACdC,QAAQnE,oBAAI;MACZoE,OAAOpE,oBAAI;MAAiByB,WAC3BgC,UAAK;mDAEDzD,oBAAI;yDACsCyD,MAAMY,MAAK,GAClDZ,MAAMa,YAAY,KAAK,UAAS;;wDAGMb,MAAMX,YAAW;;kBAExD;wDAAA,OAAA,EAAA,CAAA;wDAEFY,MAAI;QAAC5C,SAAS2C;QAAO1C,QAAQ;QAAC,CAAA;wDAAA,OAAA,EAAA,CAAA;OAAA;MAGlC,CAAA;iDAEFf,oBAAI,6HACHgB,QACD,CAAA;kCACwB;KAAA;;GAAA,CAAA;EAAA"}
1
+ {"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","usePowerlines","Usage","getAppBin","sortOptions","kebabCase","snakeCase","useTheme","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","padding","app","_$createIntrinsic","HelpOptions","options","option","flags","names","name","length","push","alias","forEach","sort","join","kind","string","variadic","number","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","values","child","BaseHelp","filterGlobalOptions","filter","some","globalOption","includes","when","value","VirtualHelp","path","doubleHardline","joiner","ender","title","isVirtual","segments","CommandHelp"],"sources":["../../src/components/help.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { Usage } from \"@shell-shock/core/components/usage\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { sortOptions } from \"@shell-shock/core/plugin-utils/reflect\";\nimport type {\n CommandOption,\n CommandTree,\n CommandTreePath\n} from \"@shell-shock/core/types/command\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { useTheme } from \"../contexts\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface HelpUsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 2\n */\n indent?: number;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function HelpUsage(props: HelpUsageProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const theme = useTheme();\n\n return (\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.primary(\"`}\n <Usage bin={bin} command={command} />\n {code`\"), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n );\n}\n\nexport interface HelpOptionsProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n}\n\n/**\n * A component that generates the options table display for a command.\n */\nexport function HelpOptions(props: HelpOptionsProps) {\n const { options } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={sortOptions(options)} hardline>\n {option => {\n const flags = [] as string[];\n const names = [] as string[];\n if (option.name.length === 1) {\n flags.push(`-${option.name}`);\n } else {\n names.push(`--${kebabCase(option.name)}`);\n }\n\n option.alias.forEach((alias: string) => {\n if (alias.length === 1) {\n flags.push(`-${alias}`);\n } else {\n names.push(`--${kebabCase(alias)}`);\n }\n });\n\n return code`[{ value: colors.text.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === ReflectionKind.string\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === ReflectionKind.number\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${option.description.replace(\n /\\.+$/,\n \"\"\n )} ${\n option.env || option.default !== undefined\n ? `(${\n option.env\n ? `env: ${context.config.envPrefix}_${option.env}${\n option.default !== undefined ? \", \" : \"\"\n }`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default)}`\n : \"\"\n })`\n : \"\"\n }.\"), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsProps {\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n}\n\n/**\n * A component that generates the commands table display for a command.\n */\nexport function HelpCommands(props: HelpCommandsProps) {\n const { commands } = props;\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={Object.values(commands)} hardline>\n {child =>\n code`[{ value: colors.text.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${child.description.replace(\n /\\.+$/,\n \"\"\n )}\"), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * Whether to filter out global options from the help display.\n *\n * @remarks\n * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.\n *\n * @defaultValue false\n */\n filterGlobalOptions?: boolean;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function BaseHelp(props: BaseHelpProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<ScriptPresetContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n )\n : Object.values(command.options)\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsage command={command} indent={indent} />\n <hbr />\n <hbr />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptions options={options.value} />\n <hbr />\n <hbr />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommands commands={command.children} />\n <hbr />\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface VirtualHelpProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n\n /**\n * The command path to generate help for, used for generating the help invocation instructions.\n *\n * @remarks\n * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).\n */\n path?: CommandTreePath;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualHelp(props: VirtualHelpProps) {\n const { options, path, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptions options={options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${\n child.isVirtual ? \"\" : \"Command\"\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )}${\n path?.segments && path.segments.length > 0\n ? ` ${path.segments.join(\" \")}`\n : \"\"\n } <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpProps {\n /**\n * A mapping of command names to their command definitions.\n */\n command: CommandTree;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function CommandHelp(props: CommandHelpProps) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <BaseHelp command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${\n child.isVirtual ? \"\" : \"Command\"\n }\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )} ${command.path.segments.join(\" \")} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,SAAgBY,UAAUC,OAAuB;CAC/C,MAAM,EAAEC,SAASC,SAAS,MAAMF;CAEhC,MAAMG,8EAA8C;CACpD,MAAMC,QAAQN,iCAAU;AAExB,yDACGT,qBAAG;EAAA,IAACiB,OAAI;AAAA,UAAEC,OAAOC,KAAKL,QAAQM,OAAOC,IAAI;;EAAEC,UAAQ;EAAAC,WACjDF,QAAG;GAECvB,oBAAI;;;oDAGJM,2CAAK;IAAMiB;IAAcT;IAAO,CAAA;+CAChCd,oBAAI,kBAAkBiB,MAAMU,QAAQC,MAAMb,OAAM;UAClD;oDAAA,OAAA,EAAA,CAAA;GAAA;EAGF,CAAA;;;;;AAeP,SAAgBe,YAAYjB,OAAyB;CACnD,MAAM,EAAEkB,YAAYlB;CAEpB,MAAMG,8EAA8C;AAEpD,QAAA;EAEKhB,oBAAI;mDAAU,OAAA,EAAA,CAAA;mDAEdE,qBAAG;GAAA,IAACiB,OAAI;AAAA,oEAAcY,QAAQ;;GAAEP,UAAQ;GAAAC,WACtCO,WAAU;IACT,MAAMC,QAAQ,EAAc;IAC5B,MAAMC,QAAQ,EAAc;AAC5B,QAAIF,OAAOG,KAAKC,WA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@ -1,5 +1,5 @@
1
- import * as _alloy_js_core7 from "@alloy-js/core";
2
- import { CommandOption, CommandTree } from "@shell-shock/core/types/command";
1
+ import * as _alloy_js_core5 from "@alloy-js/core";
2
+ import { CommandOption, CommandTree, CommandTreePath } from "@shell-shock/core/types/command";
3
3
 
4
4
  //#region src/components/help.d.ts
5
5
  interface HelpUsageProps {
@@ -20,7 +20,7 @@ interface HelpUsageProps {
20
20
  /**
21
21
  * A component that generates the usage display for a command.
22
22
  */
23
- declare function HelpUsage(props: HelpUsageProps): _alloy_js_core7.Children;
23
+ declare function HelpUsage(props: HelpUsageProps): _alloy_js_core5.Children;
24
24
  interface HelpOptionsProps {
25
25
  /**
26
26
  * The options to display help for.
@@ -30,7 +30,7 @@ interface HelpOptionsProps {
30
30
  /**
31
31
  * A component that generates the options table display for a command.
32
32
  */
33
- declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core7.Children;
33
+ declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core5.Children;
34
34
  interface HelpCommandsProps {
35
35
  /**
36
36
  * A mapping of command names to their command definitions.
@@ -40,12 +40,21 @@ interface HelpCommandsProps {
40
40
  /**
41
41
  * A component that generates the commands table display for a command.
42
42
  */
43
- declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core7.Children;
44
- interface HelpProps {
43
+ declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core5.Children;
44
+ interface BaseHelpProps {
45
45
  /**
46
46
  * The command to generate help for.
47
47
  */
48
48
  command: CommandTree;
49
+ /**
50
+ * Whether to filter out global options from the help display.
51
+ *
52
+ * @remarks
53
+ * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.
54
+ *
55
+ * @defaultValue false
56
+ */
57
+ filterGlobalOptions?: boolean;
49
58
  /**
50
59
  * The padding scale to apply to the help display headings.
51
60
  *
@@ -59,8 +68,8 @@ interface HelpProps {
59
68
  /**
60
69
  * A component that generates the `help` function declaration for a command.
61
70
  */
62
- declare function Help(props: HelpProps): _alloy_js_core7.Children;
63
- interface HelpInvokeProps {
71
+ declare function BaseHelp(props: BaseHelpProps): _alloy_js_core5.Children;
72
+ interface VirtualHelpProps {
64
73
  /**
65
74
  * The options to display help for.
66
75
  */
@@ -69,11 +78,28 @@ interface HelpInvokeProps {
69
78
  * A mapping of command names to their command definitions.
70
79
  */
71
80
  commands: Record<string, CommandTree>;
81
+ /**
82
+ * The command path to generate help for, used for generating the help invocation instructions.
83
+ *
84
+ * @remarks
85
+ * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).
86
+ */
87
+ path?: CommandTreePath;
88
+ }
89
+ /**
90
+ * A component that generates the invocation of the `help` function for a command.
91
+ */
92
+ declare function VirtualHelp(props: VirtualHelpProps): _alloy_js_core5.Children;
93
+ interface CommandHelpProps {
94
+ /**
95
+ * A mapping of command names to their command definitions.
96
+ */
97
+ command: CommandTree;
72
98
  }
73
99
  /**
74
100
  * A component that generates the invocation of the `help` function for a command.
75
101
  */
76
- declare function HelpInvoke(props: HelpInvokeProps): _alloy_js_core7.Children;
102
+ declare function CommandHelp(props: CommandHelpProps): _alloy_js_core5.Children;
77
103
  //#endregion
78
- export { Help, HelpCommands, HelpCommandsProps, HelpInvoke, HelpInvokeProps, HelpOptions, HelpOptionsProps, HelpProps, HelpUsage, HelpUsageProps };
104
+ export { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps };
79
105
  //# sourceMappingURL=help.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.cts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAiCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAuBR;AAUjB;AA+DA;AAUA;AAuBA;AAoBA;AAqDA;;EAS2B,MAAA,CAAA,EAAA,MAAA;;;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