@shell-shock/preset-script 0.6.21 → 0.6.22
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 +5 -5
- package/dist/components/banner-function-declaration.cjs.map +1 -1
- package/dist/components/banner-function-declaration.d.cts.map +1 -1
- package/dist/components/banner-function-declaration.d.mts.map +1 -1
- package/dist/components/banner-function-declaration.mjs +1 -1
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/bin-entry.cjs +3 -2
- package/dist/components/bin-entry.cjs.map +1 -1
- package/dist/components/bin-entry.mjs +2 -1
- package/dist/components/bin-entry.mjs.map +1 -1
- package/dist/components/command-entry.cjs +13 -13
- package/dist/components/command-entry.cjs.map +1 -1
- package/dist/components/command-entry.d.cts +1 -1
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +1 -1
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +10 -10
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +2 -2
- package/dist/components/command-router.cjs.map +1 -1
- package/dist/components/command-router.mjs +1 -1
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/exit-function-declaration.cjs +4 -4
- package/dist/components/exit-function-declaration.cjs.map +1 -1
- package/dist/components/exit-function-declaration.d.cts +2 -2
- package/dist/components/exit-function-declaration.d.mts +2 -2
- package/dist/components/exit-function-declaration.mjs +1 -1
- package/dist/components/exit-function-declaration.mjs.map +1 -1
- package/dist/components/help.cjs +9 -10
- package/dist/components/help.cjs.map +1 -1
- package/dist/components/help.d.cts +8 -8
- package/dist/components/help.d.cts.map +1 -1
- package/dist/components/help.d.mts +1 -1
- package/dist/components/help.d.mts.map +1 -1
- package/dist/components/help.mjs +6 -7
- package/dist/components/help.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +4 -3
- package/dist/components/virtual-command-entry.cjs.map +1 -1
- package/dist/components/virtual-command-entry.mjs +2 -1
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-default-options.cjs +6 -6
- package/dist/helpers/get-default-options.cjs.map +1 -1
- package/dist/helpers/get-default-options.mjs +6 -6
- package/dist/helpers/get-default-options.mjs.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +13 -27
- package/dist/components/helpers.cjs +0 -54
- package/dist/components/helpers.cjs.map +0 -1
- package/dist/components/helpers.d.cts +0 -29
- package/dist/components/helpers.d.cts.map +0 -1
- package/dist/components/helpers.d.mts +0 -29
- package/dist/components/helpers.d.mts.map +0 -1
- package/dist/components/helpers.mjs +0 -50
- package/dist/components/helpers.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-function-declaration.cjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","Spacing","usePowerlines","IsVerbose","getAppTitle","ExitFunctionDeclaration","context","_$createComponent","name","doc","children","optional","type","_$createIntrinsic","initializer","async","parameters","default","_$memo","condition"],"sources":["../../src/components/exit-function-declaration.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 } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { IsVerbose } from \"@shell-shock/core/components/helpers\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils
|
|
1
|
+
{"version":3,"file":"exit-function-declaration.cjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","Spacing","usePowerlines","IsVerbose","getAppTitle","ExitFunctionDeclaration","context","_$createComponent","name","doc","children","optional","type","_$createIntrinsic","initializer","async","parameters","default","_$memo","condition"],"sources":["../../src/components/exit-function-declaration.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 } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { IsVerbose } from \"@shell-shock/core/components/helpers\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * The `exit` handler function declaration code for the Shell Shock project.\n */\nexport function ExitFunctionDeclaration() {\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"ExitOptions\"\n doc=\"Options for the exit handler function.\">\n <InterfaceMember\n name=\"exception\"\n optional\n type=\"string | Error\"\n doc=\"An optional exception that caused the exit. This can be a string message or an Error object.\"\n />\n <hbr />\n <InterfaceMember\n name=\"skipProcessExit\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application.\"\n />\n <hbr />\n <InterfaceMember\n name=\"isSynchronous\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed.\"\n />\n <hbr />\n <InterfaceMember\n name=\"signal\"\n optional\n type=\"number\"\n doc=\"The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM).\"\n />\n <hbr />\n <InterfaceMember\n name=\"startDate\"\n optional\n type=\"Date\"\n doc=\"A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process.\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <VarDeclaration\n let\n name=\"isExiting\"\n type=\"boolean\"\n initializer={code`false;`}\n />\n <VarDeclaration\n const\n name=\"callbackAsyncQueue\"\n type=\"Array<[(code: number | string) => Promise<void> | void, number]>\"\n initializer={code`[];`}\n />\n <VarDeclaration\n const\n name=\"callbackSyncQueue\"\n type=\"Array<(code: number | string) => void>\"\n initializer={code`[];`}\n />\n <Spacing />\n <FunctionDeclaration\n export\n async\n name=\"exit\"\n parameters={[\n {\n name: \"options\",\n type: \"ExitOptions\",\n default: \"{}\"\n }\n ]}>\n {code`\n try {\n if (isExiting) {\n return;\n }\n\n isExiting = true;\n\n let exitCode: number | string = 0;\n if ((options.signal !== undefined && options.signal > 0) || options.exception) {\n exitCode = 128 + (options.signal ?? 1);\n } else if (typeof process.exitCode === \"number\" || typeof process.exitCode === \"string\") {\n exitCode = process.exitCode;\n }\n\n if (options.exception) {\n error(\\`A fatal error occured while running the application - please contact the ${getAppTitle(\n context\n )} support team\\${options.exception && typeof options.exception !== \"symbol\" ? \\`: \\\\n\\\\n\\${typeof options.exception === \"string\" ? options.exception : options.exception.message}\\` : \".\"}\\`);\n }\n\n const terminate = (force = false) => { `}\n <IfStatement\n condition={<IsVerbose />}>{code`writeLine(\"\");`}</IfStatement>\n <hbr />\n {code`\n verbose(\\`The ${getAppTitle(\n context\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}\\${options.startDate ? \\`. Total processing time is \\${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \\${Date.now() - options.startDate.getTime() > 5000 ? \"seconds\" : \"milliseconds\"}\\` : \"\"}...\\`);\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(exitCode));\n }\n };\n\n for (const callbackSync of callbackSyncQueue) {\n callbackSync(exitCode);\n }\n\n if (!options.isSynchronous) {\n const promises = [];\n let forceAfter = 0;\n for (const [callbackAsync, wait] of callbackAsyncQueue) {\n forceAfter = Math.max(forceAfter, wait);\n promises.push(Promise.resolve(callbackAsync(exitCode)));\n }\n\n const asyncTimer = setTimeout(() => {\n terminate(true);\n }, forceAfter);\n await Promise.all(promises);\n clearTimeout(asyncTimer);\n }\n\n terminate();\n } catch (err) {\n error(\\`The exit process failed to complete\\${(err as Error)?.message ? \\` - \\${(err as Error).message}\\` : \"\"}. Please contact the ${getAppTitle(\n context\n )} support team.\\`);\n\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(1));\n }\n }\n `}\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAmCA,SAAgBU,0BAA0B;CACxC,MAAMC,8EAA8C;AAEpD,QAAA;mDAEKR,4CAAoB;GAAA,UAAA;GAEnBU,MAAI;GACJC,KAAG;GAAA,IAAAC,WAAA;AAAA,WAAA;sDACFX,uCAAe;MACdS,MAAI;MACJG,UAAQ;MACRC,MAAI;MACJH,KAAG;MAAA,CAAA;sDAAA,OAAA,E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|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core5 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/components/exit-function-declaration.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The `exit` handler function declaration code for the Shell Shock project.
|
|
6
6
|
*/
|
|
7
|
-
declare function ExitFunctionDeclaration():
|
|
7
|
+
declare function ExitFunctionDeclaration(): _alloy_js_core5.Children;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ExitFunctionDeclaration };
|
|
10
10
|
//# sourceMappingURL=exit-function-declaration.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core5 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/components/exit-function-declaration.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The `exit` handler function declaration code for the Shell Shock project.
|
|
6
6
|
*/
|
|
7
|
-
declare function ExitFunctionDeclaration():
|
|
7
|
+
declare function ExitFunctionDeclaration(): _alloy_js_core5.Children;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ExitFunctionDeclaration };
|
|
10
10
|
//# sourceMappingURL=exit-function-declaration.d.mts.map
|
|
@@ -3,7 +3,7 @@ import { code } from "@alloy-js/core";
|
|
|
3
3
|
import { FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
4
4
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
5
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
-
import { getAppTitle } from "@shell-shock/core/plugin-utils
|
|
6
|
+
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
7
7
|
import { IsVerbose } from "@shell-shock/core/components/helpers";
|
|
8
8
|
|
|
9
9
|
//#region src/components/exit-function-declaration.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-function-declaration.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","Spacing","usePowerlines","IsVerbose","getAppTitle","ExitFunctionDeclaration","context","_$createComponent","name","doc","children","optional","type","_$createIntrinsic","initializer","async","parameters","default","_$memo","condition"],"sources":["../../src/components/exit-function-declaration.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 } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { IsVerbose } from \"@shell-shock/core/components/helpers\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils
|
|
1
|
+
{"version":3,"file":"exit-function-declaration.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","Spacing","usePowerlines","IsVerbose","getAppTitle","ExitFunctionDeclaration","context","_$createComponent","name","doc","children","optional","type","_$createIntrinsic","initializer","async","parameters","default","_$memo","condition"],"sources":["../../src/components/exit-function-declaration.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 } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { IsVerbose } from \"@shell-shock/core/components/helpers\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * The `exit` handler function declaration code for the Shell Shock project.\n */\nexport function ExitFunctionDeclaration() {\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"ExitOptions\"\n doc=\"Options for the exit handler function.\">\n <InterfaceMember\n name=\"exception\"\n optional\n type=\"string | Error\"\n doc=\"An optional exception that caused the exit. This can be a string message or an Error object.\"\n />\n <hbr />\n <InterfaceMember\n name=\"skipProcessExit\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application.\"\n />\n <hbr />\n <InterfaceMember\n name=\"isSynchronous\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed.\"\n />\n <hbr />\n <InterfaceMember\n name=\"signal\"\n optional\n type=\"number\"\n doc=\"The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM).\"\n />\n <hbr />\n <InterfaceMember\n name=\"startDate\"\n optional\n type=\"Date\"\n doc=\"A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process.\"\n />\n </InterfaceDeclaration>\n <Spacing />\n <VarDeclaration\n let\n name=\"isExiting\"\n type=\"boolean\"\n initializer={code`false;`}\n />\n <VarDeclaration\n const\n name=\"callbackAsyncQueue\"\n type=\"Array<[(code: number | string) => Promise<void> | void, number]>\"\n initializer={code`[];`}\n />\n <VarDeclaration\n const\n name=\"callbackSyncQueue\"\n type=\"Array<(code: number | string) => void>\"\n initializer={code`[];`}\n />\n <Spacing />\n <FunctionDeclaration\n export\n async\n name=\"exit\"\n parameters={[\n {\n name: \"options\",\n type: \"ExitOptions\",\n default: \"{}\"\n }\n ]}>\n {code`\n try {\n if (isExiting) {\n return;\n }\n\n isExiting = true;\n\n let exitCode: number | string = 0;\n if ((options.signal !== undefined && options.signal > 0) || options.exception) {\n exitCode = 128 + (options.signal ?? 1);\n } else if (typeof process.exitCode === \"number\" || typeof process.exitCode === \"string\") {\n exitCode = process.exitCode;\n }\n\n if (options.exception) {\n error(\\`A fatal error occured while running the application - please contact the ${getAppTitle(\n context\n )} support team\\${options.exception && typeof options.exception !== \"symbol\" ? \\`: \\\\n\\\\n\\${typeof options.exception === \"string\" ? options.exception : options.exception.message}\\` : \".\"}\\`);\n }\n\n const terminate = (force = false) => { `}\n <IfStatement\n condition={<IsVerbose />}>{code`writeLine(\"\");`}</IfStatement>\n <hbr />\n {code`\n verbose(\\`The ${getAppTitle(\n context\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}\\${options.startDate ? \\`. Total processing time is \\${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \\${Date.now() - options.startDate.getTime() > 5000 ? \"seconds\" : \"milliseconds\"}\\` : \"\"}...\\`);\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(exitCode));\n }\n };\n\n for (const callbackSync of callbackSyncQueue) {\n callbackSync(exitCode);\n }\n\n if (!options.isSynchronous) {\n const promises = [];\n let forceAfter = 0;\n for (const [callbackAsync, wait] of callbackAsyncQueue) {\n forceAfter = Math.max(forceAfter, wait);\n promises.push(Promise.resolve(callbackAsync(exitCode)));\n }\n\n const asyncTimer = setTimeout(() => {\n terminate(true);\n }, forceAfter);\n await Promise.all(promises);\n clearTimeout(asyncTimer);\n }\n\n terminate();\n } catch (err) {\n error(\\`The exit process failed to complete\\${(err as Error)?.message ? \\` - \\${(err as Error).message}\\` : \"\"}. Please contact the ${getAppTitle(\n context\n )} support team.\\`);\n\n if (!options.skipProcessExit) {\n process.nextTick(() => process.exit(1));\n }\n }\n `}\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAmCA,SAAgBU,0BAA0B;CACxC,MAAMC,UAAUJ,eAAoC;AAEpD,QAAA;EAAAK,gBAEKT,sBAAoB;GAAA,UAAA;GAEnBU,MAAI;GACJC,KAAG;GAAA,IAAAC,WAAA;AAAA,WAAA;KAAAH,gBACFR,iBAAe;MACdS,MAAI;MACJG,UAAQ;MACRC,MAAI;MACJH,KAAG;MAAA,CAAA;KAAAI,gBAAA,OAAA,EAAA,CAAA;KAAAN,gBAGJR,iBAAe;MACdS,MAAI;MACJG,UAAQ;MACRC,MAAI;MACJH,KAAG;MAAA,CAAA;KAAAI,gBAAA,OAAA,EAAA,CAAA;KAAAN,gBAGJR,iBAAe;MACdS,MAAI;MACJG,UAAQ;MACRC,MAAI;MACJH,KAAG;MAAA,CAAA;KAAAI,gBAAA,OAAA,EAAA,CAAA;KAAAN,gBAGJR,iBAAe;MACdS,MAAI;MACJG,UAAQ;MACRC,MAAI;MACJH,KAAG;MAAA,CAAA;KAAAI,gBAAA,OAAA,EAAA,CAAA;KAAAN,gBAGJR,iBAAe;MACdS,MAAI;MACJG,UAAQ;MACRC,MAAI;MACJH,KAAG;MAAA,CAAA;KAAA;;GAAA,CAAA;EAAAF,gBAGNN,SAAO,EAAA,CAAA;EAAAM,gBACPP,gBAAc;GAAA,OAAA;GAEbQ,MAAI;GACJI,MAAI;GACJE,aAAanB,IAAI;GAAQ,CAAA;EAAAY,gBAE1BP,gBAAc;GAAA,SAAA;GAEbQ,MAAI;GACJI,MAAI;GACJE,aAAanB,IAAI;GAAK,CAAA;EAAAY,gBAEvBP,gBAAc;GAAA,SAAA;GAEbQ,MAAI;GACJI,MAAI;GACJE,aAAanB,IAAI;GAAK,CAAA;EAAAY,gBAEvBN,SAAO,EAAA,CAAA;EAAAM,gBACPX,qBAAmB;GAAA,UAAA;GAElBmB,OAAK;GACLP,MAAI;GACJQ,YAAY,CACV;IACER,MAAM;IACNI,MAAM;IACNK,SAAS;IACV,CACF;GAAA,IAAAP,WAAA;AAAA,WAAA;KAAAQ,WACAvB,IAAI;;;;;;;;;;;;;;;;iGAgBoFS,YACjFE,QACD,CAAA;;;qDAGqC;KAAAC,gBAC3CV,aAAW;MAAA,IACVsB,YAAS;AAAA,cAAAZ,gBAAGJ,WAAS,EAAA,CAAA;;MAAAO,UAAMf,IAAI;MAAgB,CAAA;KAAAkB,gBAAA,OAAA,EAAA,CAAA;KAAAK,WAEhDvB,IAAI;8BACiBS,YACdE,QACD,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;kJA2BmIF,YACpIE,QACD,CAAA;;;;;;UAMJ;KAAA;;GAAA,CAAA;EAAA"}
|
package/dist/components/help.cjs
CHANGED
|
@@ -3,11 +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 __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
5
5
|
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
6
|
-
let
|
|
6
|
+
let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
7
7
|
let __shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
8
|
-
let
|
|
8
|
+
let __shell_shock_core = require("@shell-shock/core");
|
|
9
9
|
let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
10
|
-
let __shell_shock_core_plugin_utils_reflect = require("@shell-shock/core/plugin-utils/reflect");
|
|
11
10
|
let __stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
|
|
12
11
|
|
|
13
12
|
//#region src/components/help.tsx
|
|
@@ -25,11 +24,11 @@ function HelpUsage(props) {
|
|
|
25
24
|
hardline: true,
|
|
26
25
|
children: (bin) => [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
|
|
27
26
|
writeLine(
|
|
28
|
-
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${(0,
|
|
27
|
+
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${(0, __shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? "dynamic" : "command"}("${(0, __shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? `[${(0, __stryke_string_format_snake_case.snakeCase)((0, __shell_shock_core_plugin_utils.getDynamicPathSegmentName)(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${colors.text.usage.args("<${(0, __stryke_string_format_snake_case.snakeCase)((arg.kind === __shell_shock_core.CommandParameterKinds.string || arg.kind === __shell_shock_core.CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === __shell_shock_core.CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === __shell_shock_core.CommandParameterKinds.string || arg.kind === __shell_shock_core.CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""} \${colors.text.usage.options("[options]")}\`), { padding: ${theme.padding.app * indent} }
|
|
29
28
|
);`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})]
|
|
30
29
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
31
30
|
get when() {
|
|
32
|
-
return command.
|
|
31
|
+
return command.args.length > 0;
|
|
33
32
|
},
|
|
34
33
|
get children() {
|
|
35
34
|
return [(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
@@ -39,7 +38,7 @@ function HelpUsage(props) {
|
|
|
39
38
|
hardline: true,
|
|
40
39
|
children: (bin) => [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
|
|
41
40
|
writeLine(
|
|
42
|
-
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${(0,
|
|
41
|
+
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${(0, __shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? "dynamic" : "command"}("${(0, __shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? `[${(0, __stryke_string_format_snake_case.snakeCase)((0, __shell_shock_core_plugin_utils.getDynamicPathSegmentName)(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""} \${colors.text.usage.options("[options]")}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${colors.text.usage.args("<${(0, __stryke_string_format_snake_case.snakeCase)((arg.kind === __shell_shock_core.CommandParameterKinds.string || arg.kind === __shell_shock_core.CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === __shell_shock_core.CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === __shell_shock_core.CommandParameterKinds.string || arg.kind === __shell_shock_core.CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""}\`), { padding: ${theme.padding.app * indent} }
|
|
43
42
|
);`), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})]
|
|
44
43
|
})];
|
|
45
44
|
}
|
|
@@ -56,7 +55,7 @@ function HelpOptions(props) {
|
|
|
56
55
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
57
56
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
58
57
|
get each() {
|
|
59
|
-
return (0,
|
|
58
|
+
return (0, __shell_shock_core_plugin_utils.sortOptions)(options);
|
|
60
59
|
},
|
|
61
60
|
hardline: true,
|
|
62
61
|
children: (option) => {
|
|
@@ -68,7 +67,7 @@ function HelpOptions(props) {
|
|
|
68
67
|
if (alias.length === 1) flags.push(`-${alias}`);
|
|
69
68
|
else names.push(`--${(0, __stryke_string_format_kebab_case.kebabCase)(alias)}`);
|
|
70
69
|
});
|
|
71
|
-
return __alloy_js_core.code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind ===
|
|
70
|
+
return __alloy_js_core.code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind === __shell_shock_core.CommandParameterKinds.string ? ` <${(0, __stryke_string_format_snake_case.snakeCase)(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.format ? option.format : option.name)}${option.variadic ? "..." : ""}>` : option.kind === __shell_shock_core.CommandParameterKinds.number ? ` <${(0, __stryke_string_format_snake_case.snakeCase)(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.name)}${option.variadic ? "..." : ""}>` : ""}"), align: "right", border: "none", maxWidth: "1/3" }, { value: colors.text.body.tertiary("${option.description.replace(/\.+$/, "")} ${option.env || option.default !== void 0 ? `(${option.env ? `env: ${context.config.envPrefix}_${option.env}${option.default !== void 0 ? ", " : ""}` : ""}${option.default !== void 0 ? `default: ${JSON.stringify(option.default).replace(/"/g, "\\\"")}` : ""})` : ""}."), align: "left", border: "none" }], `;
|
|
72
71
|
}
|
|
73
72
|
}),
|
|
74
73
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
@@ -192,7 +191,7 @@ function VirtualHelp(props) {
|
|
|
192
191
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
193
192
|
]
|
|
194
193
|
}),
|
|
195
|
-
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0,
|
|
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.getAppBin)(context)}${segments && segments.length > 0 ? ` ${segments.join(" ")}` : ""} <specific command> --help') will provide additional information that is specific to that command.");
|
|
196
195
|
writeLine("");`)
|
|
197
196
|
];
|
|
198
197
|
}
|
|
@@ -247,7 +246,7 @@ function CommandHelp(props) {
|
|
|
247
246
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
248
247
|
]
|
|
249
248
|
}),
|
|
250
|
-
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`help("Running a specific command with the help flag (via: '${(0,
|
|
249
|
+
(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.getAppBin)(context)} ${command.segments.join(" ")} <specific command> --help') will provide additional information that is specific to that command.");
|
|
251
250
|
writeLine("");`)
|
|
252
251
|
];
|
|
253
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","Spacing","usePowerlines","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","sortOptions","useTheme","kebabCase","snakeCase","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","segments","length","map","segment","join","values","arguments","argument","name","kind","string","number","variadic","padding","app","_$createIntrinsic","when","HelpOptions","options","option","flags","names","push","alias","forEach","sort","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","child","BaseHelp","filterGlobalOptions","filter","some","globalOption","includes","value","VirtualHelp","doubleHardline","joiner","ender","icon","title","isVirtual","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 { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\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 { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\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 <>\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"}${\n command.arguments.length > 0\n ? ` ${command.arguments\n .map(\n argument =>\n `\\${colors.text.usage.arguments(\"<${snakeCase(argument.name)}${\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${colors.text.usage.options(\"[options]\")}\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n <Show when={command.arguments.length > 0}>\n <hbr />\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"} \\${colors.text.usage.options(\"[options]\")}${\n command.arguments.length > 0\n ? ` ${command.arguments\n .map(\n argument =>\n `\\${colors.text.usage.arguments(\"<${snakeCase(argument.name)}${\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n </Show>\n </>\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\", maxWidth: \"1/3\" }, { 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).replace(/\"/g, '\\\\\"')}`\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 <Spacing />\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 segments?: string[];\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, segments, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptions options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\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(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\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 segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\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 <Spacing />\n <BaseHelp command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\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(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\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.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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EAAA,CAAA;mDACPF,sBAAI;GAAA,IAAC0C,OAAI;AAAA,WAAEvB,OAAOC,KAAKP,QAAQW,SAAS,CAACG,SAAS;;GAAC,IAAAH,WAAA;AAAA,WAAA;KACjD3B,oBAAI;;sDACW,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAGfE,qBAAG;MAAA,IACFmB,OAAI;AAAA,cAAEC,OAAOY,OAAOlB,QAAQW,SAAS;;MACrC+C,gBAAc;MACdC,QAAQ3E,oBAAI;MACZ4E,OAAO5E,oBAAI;MAAiB2B,WAC3BsC,UAAK;mDAEDjE,oBAAI;wDAEDiE,MAAMY,OACF,2BAA2BZ,MAAMY,KAAI,gBACrC,GAAE,GACJZ,MAAMa,MAAK,GAAIb,MAAMc,YAAY,KAAK,UAAS;;wDAEXd,MAAMV,YAAW;;kBAExD;wDAAA,OAAA,EAAA,CAAA;wDAEFW,UAAQ;QAAClD,SAASiD;QAAOhD,QAAQ;QAAGkD,qBAAmB;QAAA,CAAA;wDAAA,OAAA,EAAA,CAAA;OAAA;MAG3D,CAAA;iDAEFnE,oBAAI,6HACHkB,QACD,CAAA,GAAIF,QAAQa,SAASI,KACpB,IACD,CAAA;wBACc;KAAA;;GAAA,CAAA;EAAA"}
|
|
1
|
+
{"version":3,"file":"help.cjs","names":["code","computed","For","Show","Spacing","usePowerlines","CommandParameterKinds","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","sortOptions","useTheme","kebabCase","snakeCase","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","segments","length","map","segment","join","values","args","arg","kind","string","number","choices","format","name","variadic","padding","app","_$createIntrinsic","when","HelpOptions","options","option","flags","names","push","alias","forEach","sort","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","child","BaseHelp","filterGlobalOptions","filter","some","globalOption","includes","value","VirtualHelp","doubleHardline","joiner","ender","icon","title","isVirtual","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 { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandOption, CommandTree } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n sortOptions\n} from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\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 <>\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"}${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${colors.text.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${colors.text.usage.options(\"[options]\")}\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n <Show when={command.args.length > 0}>\n <hbr />\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"} \\${colors.text.usage.options(\"[options]\")}${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${colors.text.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n </Show>\n </>\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 === CommandParameterKinds.string\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.format\n ? option.format\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === CommandParameterKinds.number\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\", maxWidth: \"1/3\" }, { value: 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).replace(/\"/g, '\\\\\"')}`\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 <Spacing />\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 segments?: string[];\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, segments, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptions options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\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(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\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 segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\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 <Spacing />\n <BaseHelp command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\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(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\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.segments.join(\n \" \"\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;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OAAA;MAG3D,CAAA;iDAEFrE,oBAAI,6GACHkB,QACD,CAAA,GAAIF,QAAQa,SAASI,KACpB,IACD,CAAA;wBACc;KAAA;;GAAA,CAAA;EAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { CommandOption, CommandTree } from "@shell-shock/core
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
import { CommandOption, CommandTree } from "@shell-shock/core";
|
|
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):
|
|
23
|
+
declare function HelpUsage(props: HelpUsageProps): _alloy_js_core0.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):
|
|
33
|
+
declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core0.Children;
|
|
34
34
|
interface HelpCommandsProps {
|
|
35
35
|
/**
|
|
36
36
|
* A mapping of command names to their command definitions.
|
|
@@ -40,7 +40,7 @@ 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):
|
|
43
|
+
declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core0.Children;
|
|
44
44
|
interface BaseHelpProps {
|
|
45
45
|
/**
|
|
46
46
|
* The command to generate help for.
|
|
@@ -68,7 +68,7 @@ interface BaseHelpProps {
|
|
|
68
68
|
/**
|
|
69
69
|
* A component that generates the `help` function declaration for a command.
|
|
70
70
|
*/
|
|
71
|
-
declare function BaseHelp(props: BaseHelpProps):
|
|
71
|
+
declare function BaseHelp(props: BaseHelpProps): _alloy_js_core0.Children;
|
|
72
72
|
interface VirtualHelpProps {
|
|
73
73
|
/**
|
|
74
74
|
* The options to display help for.
|
|
@@ -89,7 +89,7 @@ interface VirtualHelpProps {
|
|
|
89
89
|
/**
|
|
90
90
|
* A component that generates the invocation of the `help` function for a command.
|
|
91
91
|
*/
|
|
92
|
-
declare function VirtualHelp(props: VirtualHelpProps):
|
|
92
|
+
declare function VirtualHelp(props: VirtualHelpProps): _alloy_js_core0.Children;
|
|
93
93
|
interface CommandHelpProps {
|
|
94
94
|
/**
|
|
95
95
|
* A mapping of command names to their command definitions.
|
|
@@ -99,7 +99,7 @@ interface CommandHelpProps {
|
|
|
99
99
|
/**
|
|
100
100
|
* A component that generates the invocation of the `help` function for a command.
|
|
101
101
|
*/
|
|
102
|
-
declare function CommandHelp(props: CommandHelpProps):
|
|
102
|
+
declare function CommandHelp(props: CommandHelpProps): _alloy_js_core0.Children;
|
|
103
103
|
//#endregion
|
|
104
104
|
export { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps };
|
|
105
105
|
//# sourceMappingURL=help.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.cts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"help.d.cts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAkCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAiHR;AAUjB;AAyEA;AAUA;AAuBA;AA8BA;AAqDA;;EAS2B,MAAA,CAAA,EAAA,MAAA;;;AAc3B;AAoDA;AAUgB,iBA7YA,SAAA,CA6YmB,KAAA,EA7YF,cA6YkB,CAAA,EA7YJ,eAAA,CAAA,QA6YI;UA5RlC,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UAyElC,iBAAA;;;;YAIL,eAAe;;;;;iBAMX,YAAA,QAAoB,oBAAiB,eAAA,CAAA;UAuBpC,aAAA;;;;WAIN;;;;;;;;;;;;;;;;;;;;;;;iBA0BK,QAAA,QAAgB,gBAAa,eAAA,CAAA;UAqD5B,gBAAA;;;;WAIN;;;;YAKC,eAAe;;;;;;;;;;;;iBAcX,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UAoDlC,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.mts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"help.d.mts","names":[],"sources":["../../src/components/help.tsx"],"sourcesContent":[],"mappings":";;;;UAkCiB,cAAA;;;AAAjB;EAoBgB,OAAA,EAhBL,WAgBc;EAiHR;AAUjB;AAyEA;AAUA;AAuBA;AA8BA;AAqDA;;EAS2B,MAAA,CAAA,EAAA,MAAA;;;AAc3B;AAoDA;AAUgB,iBA7YA,SAAA,CA6YmB,KAAA,EA7YF,cA6YkB,CAAA,EA7YJ,eAAA,CAAA,QA6YI;UA5RlC,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UAyElC,iBAAA;;;;YAIL,eAAe;;;;;iBAMX,YAAA,QAAoB,oBAAiB,eAAA,CAAA;UAuBpC,aAAA;;;;WAIN;;;;;;;;;;;;;;;;;;;;;;;iBA0BK,QAAA,QAAgB,gBAAa,eAAA,CAAA;UAqD5B,gBAAA;;;;WAIN;;;;YAKC,eAAe;;;;;;;;;;;;iBAcX,WAAA,QAAmB,mBAAgB,eAAA,CAAA;UAoDlC,gBAAA;;;;WAIN;;;;;iBAMK,WAAA,QAAmB,mBAAgB,eAAA,CAAA"}
|
package/dist/components/help.mjs
CHANGED
|
@@ -2,11 +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 { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
4
4
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
5
|
-
import { getAppBin, getDynamicPathSegmentName, isDynamicPathSegment } from "@shell-shock/core/plugin-utils
|
|
5
|
+
import { getAppBin, getDynamicPathSegmentName, isDynamicPathSegment, sortOptions } from "@shell-shock/core/plugin-utils";
|
|
6
6
|
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
7
|
-
import {
|
|
7
|
+
import { CommandParameterKinds } from "@shell-shock/core";
|
|
8
8
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
9
|
-
import { sortOptions } from "@shell-shock/core/plugin-utils/reflect";
|
|
10
9
|
import { snakeCase } from "@stryke/string-format/snake-case";
|
|
11
10
|
|
|
12
11
|
//#region src/components/help.tsx
|
|
@@ -24,11 +23,11 @@ function HelpUsage(props) {
|
|
|
24
23
|
hardline: true,
|
|
25
24
|
children: (bin) => [memo(() => code`
|
|
26
25
|
writeLine(
|
|
27
|
-
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""}${command.
|
|
26
|
+
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${colors.text.usage.args("<${snakeCase((arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""} \${colors.text.usage.options("[options]")}\`), { padding: ${theme.padding.app * indent} }
|
|
28
27
|
);`), createIntrinsic("hbr", {})]
|
|
29
28
|
}), createComponent(Show, {
|
|
30
29
|
get when() {
|
|
31
|
-
return command.
|
|
30
|
+
return command.args.length > 0;
|
|
32
31
|
},
|
|
33
32
|
get children() {
|
|
34
33
|
return [createIntrinsic("hbr", {}), createComponent(For, {
|
|
@@ -38,7 +37,7 @@ function HelpUsage(props) {
|
|
|
38
37
|
hardline: true,
|
|
39
38
|
children: (bin) => [memo(() => code`
|
|
40
39
|
writeLine(
|
|
41
|
-
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""} \${colors.text.usage.options("[options]")}${command.
|
|
40
|
+
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""} \${colors.text.usage.options("[options]")}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${colors.text.usage.args("<${snakeCase((arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""}\`), { padding: ${theme.padding.app * indent} }
|
|
42
41
|
);`), createIntrinsic("hbr", {})]
|
|
43
42
|
})];
|
|
44
43
|
}
|
|
@@ -67,7 +66,7 @@ function HelpOptions(props) {
|
|
|
67
66
|
if (alias.length === 1) flags.push(`-${alias}`);
|
|
68
67
|
else names.push(`--${kebabCase(alias)}`);
|
|
69
68
|
});
|
|
70
|
-
return code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind ===
|
|
69
|
+
return code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind === CommandParameterKinds.string ? ` <${snakeCase(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.format ? option.format : option.name)}${option.variadic ? "..." : ""}>` : option.kind === CommandParameterKinds.number ? ` <${snakeCase(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.name)}${option.variadic ? "..." : ""}>` : ""}"), align: "right", border: "none", maxWidth: "1/3" }, { value: colors.text.body.tertiary("${option.description.replace(/\.+$/, "")} ${option.env || option.default !== void 0 ? `(${option.env ? `env: ${context.config.envPrefix}_${option.env}${option.default !== void 0 ? ", " : ""}` : ""}${option.default !== void 0 ? `default: ${JSON.stringify(option.default).replace(/"/g, "\\\"")}` : ""})` : ""}."), align: "left", border: "none" }], `;
|
|
71
70
|
}
|
|
72
71
|
}),
|
|
73
72
|
createIntrinsic("hbr", {}),
|