@shell-shock/plugin-completions 0.4.16 → 0.4.18

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 (56) hide show
  1. package/dist/components/bash-config-command.cjs +120 -6
  2. package/dist/components/bash-config-command.mjs +119 -6
  3. package/dist/components/bash-config-command.mjs.map +1 -1
  4. package/dist/components/bash-script-command.cjs +105 -5
  5. package/dist/components/bash-script-command.mjs +104 -5
  6. package/dist/components/bash-script-command.mjs.map +1 -1
  7. package/dist/components/bash-shared.cjs +77 -13
  8. package/dist/components/bash-shared.mjs +76 -13
  9. package/dist/components/bash-shared.mjs.map +1 -1
  10. package/dist/components/fish-config-command.cjs +120 -6
  11. package/dist/components/fish-config-command.mjs +119 -6
  12. package/dist/components/fish-config-command.mjs.map +1 -1
  13. package/dist/components/fish-script-command.cjs +104 -4
  14. package/dist/components/fish-script-command.mjs +103 -4
  15. package/dist/components/fish-script-command.mjs.map +1 -1
  16. package/dist/components/fish-shared.cjs +141 -77
  17. package/dist/components/fish-shared.mjs +140 -77
  18. package/dist/components/fish-shared.mjs.map +1 -1
  19. package/dist/components/index.cjs +26 -1
  20. package/dist/components/index.mjs +14 -1
  21. package/dist/components/powershell-config-command.cjs +116 -6
  22. package/dist/components/powershell-config-command.mjs +115 -6
  23. package/dist/components/powershell-config-command.mjs.map +1 -1
  24. package/dist/components/powershell-script-command.cjs +104 -4
  25. package/dist/components/powershell-script-command.mjs +103 -4
  26. package/dist/components/powershell-script-command.mjs.map +1 -1
  27. package/dist/components/powershell-shared.cjs +101 -37
  28. package/dist/components/powershell-shared.mjs +100 -37
  29. package/dist/components/powershell-shared.mjs.map +1 -1
  30. package/dist/components/zsh-config-command.cjs +120 -6
  31. package/dist/components/zsh-config-command.mjs +119 -6
  32. package/dist/components/zsh-config-command.mjs.map +1 -1
  33. package/dist/components/zsh-script-command.cjs +108 -6
  34. package/dist/components/zsh-script-command.mjs +107 -6
  35. package/dist/components/zsh-script-command.mjs.map +1 -1
  36. package/dist/components/zsh-shared.cjs +106 -42
  37. package/dist/components/zsh-shared.mjs +105 -42
  38. package/dist/components/zsh-shared.mjs.map +1 -1
  39. package/dist/helpers/complete-command.cjs +10 -1
  40. package/dist/helpers/complete-command.mjs +8 -1
  41. package/dist/helpers/complete-command.mjs.map +1 -1
  42. package/dist/helpers/completion-directive-constants.cjs +16 -1
  43. package/dist/helpers/completion-directive-constants.mjs +14 -1
  44. package/dist/helpers/completion-directive-constants.mjs.map +1 -1
  45. package/dist/helpers/index.cjs +6 -1
  46. package/dist/helpers/index.mjs +4 -1
  47. package/dist/index.cjs +303 -1
  48. package/dist/index.mjs +301 -1
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/types/index.cjs +4 -1
  51. package/dist/types/index.mjs +3 -1
  52. package/dist/types/plugin.mjs +1 -1
  53. package/dist/types/shell-type.cjs +12 -1
  54. package/dist/types/shell-type.mjs +10 -1
  55. package/dist/types/shell-type.mjs.map +1 -1
  56. package/package.json +10 -10
@@ -1,11 +1,102 @@
1
- import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{getAppBin as n,getAppTitle as r}from"@shell-shock/core/plugin-utils";import{code as i,computed as a}from"@alloy-js/core";import{ElseClause as o,FunctionDeclaration as s,IfStatement as c,InterfaceDeclaration as l,VarDeclaration as u}from"@alloy-js/typescript";import{ReflectionKind as d}from"@powerlines/deepkit/vendor/type";import{Spacing as f}from"@powerlines/plugin-alloy/core";import{usePowerlines as p}from"@powerlines/plugin-alloy/core/contexts/context";import{InterfaceMember as m,TypescriptFile as h}from"@powerlines/plugin-alloy/typescript";import{TSDoc as g,TSDocDefaultValue as _}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{joinPaths as v}from"@stryke/path";import{snakeCase as y}from"@stryke/string-format/snake-case";function b(){let b=p(),x=a(()=>n(b)),S=a(()=>y(x.value));return e(h,{get path(){return v(b.entryPath,`completions`,`zsh`,`script`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`writeLine`,`success`,`warn`,`help`]},get children(){return[e(g,{heading:`Options for the Zsh Completions - Script command.`}),e(l,{export:!0,name:`ZshScriptCompletionsOptions`,get children(){return[e(g,{heading:`Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.`,get children(){return e(_,{get type(){return d.boolean},defaultValue:!1})}}),e(m,{name:`display`,optional:!0,type:`boolean`})]}}),e(f,{}),e(g,{heading:"Handler logic for the \\`completions zsh script\\` command."}),e(s,{export:!0,default:!0,async:!0,name:`handler`,get parameters(){return[{name:`options`,type:`ZshScriptCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"${x.value}-completions.zsh"`}]},get children(){return[e(c,{condition:i`options.display !== true`,get children(){return[e(u,{const:!0,name:`scriptPath`,type:`string`,initializer:i` path.includes(".") ? \`\${path}.zsh\` : path;`}),t(()=>i`await writeFile(scriptPath, \`# Zsh script to add completions for ${r(b)}\\n\\n\${SHELL_COMPLETIONS}\`);
1
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
3
+ import { code, computed } from "@alloy-js/core";
4
+ import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
5
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { InterfaceMember as InterfaceMember$1, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
9
+ import { TSDoc as TSDoc$1, TSDocDefaultValue as TSDocDefaultValue$1 } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
+ import { joinPaths } from "@stryke/path";
11
+ import { snakeCase } from "@stryke/string-format/snake-case";
2
12
 
3
- success(\`${r(b)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)]}}),e(o,{get children(){return i`writeLine(" ------------------------------------------------- ");
13
+ //#region src/components/zsh-script-command.tsx
14
+ /**
15
+ * The Zsh Completions - Script command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function ZshScriptCompletionsCommand() {
18
+ const context = usePowerlines();
19
+ const bin = computed(() => getAppBin(context));
20
+ const name = computed(() => snakeCase(bin.value));
21
+ return createComponent(TypescriptFile, {
22
+ get path() {
23
+ return joinPaths(context.entryPath, "completions", "zsh", "script", "command.ts");
24
+ },
25
+ imports: {
26
+ "node:os": "os",
27
+ "node:path": ["join"],
28
+ "node:fs/promises": ["readFile", "writeFile"],
29
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
30
+ },
31
+ builtinImports: { console: [
32
+ "bold",
33
+ "writeLine",
34
+ "success",
35
+ "warn",
36
+ "help"
37
+ ] },
38
+ get children() {
39
+ return [
40
+ createComponent(TSDoc$1, { heading: "Options for the Zsh Completions - Script command." }),
41
+ createComponent(InterfaceDeclaration, {
42
+ "export": true,
43
+ name: "ZshScriptCompletionsOptions",
44
+ get children() {
45
+ return [createComponent(TSDoc$1, {
46
+ heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
47
+ get children() {
48
+ return createComponent(TSDocDefaultValue$1, {
49
+ get type() {
50
+ return ReflectionKind.boolean;
51
+ },
52
+ defaultValue: false
53
+ });
54
+ }
55
+ }), createComponent(InterfaceMember$1, {
56
+ name: "display",
57
+ optional: true,
58
+ type: "boolean"
59
+ })];
60
+ }
61
+ }),
62
+ createComponent(Spacing, {}),
63
+ createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions zsh script\\` command." }),
64
+ createComponent(FunctionDeclaration, {
65
+ "export": true,
66
+ "default": true,
67
+ async: true,
68
+ name: "handler",
69
+ get parameters() {
70
+ return [{
71
+ name: "options",
72
+ type: "ZshScriptCompletionsOptions",
73
+ default: "{}"
74
+ }, {
75
+ name: "path",
76
+ type: "string",
77
+ default: `"${bin.value}-completions.zsh"`
78
+ }];
79
+ },
80
+ get children() {
81
+ return [createComponent(IfStatement, {
82
+ condition: code`options.display !== true`,
83
+ get children() {
84
+ return [createComponent(VarDeclaration, {
85
+ "const": true,
86
+ name: "scriptPath",
87
+ type: "string",
88
+ initializer: code` path.includes(".") ? \`\${path}.zsh\` : path;`
89
+ }), memo(() => code`await writeFile(scriptPath, \`# Zsh script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
90
+
91
+ success(\`${getAppTitle(context)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)];
92
+ }
93
+ }), createComponent(ElseClause, { get children() {
94
+ return code`writeLine(" ------------------------------------------------- ");
4
95
  writeLine("");
5
- writeLine("#compdef ${x.value} ");
6
- writeLine("#compdef _${S.value} ${x.value}");
96
+ writeLine("#compdef ${bin.value} ");
97
+ writeLine("#compdef _${name.value} ${bin.value}");
7
98
  writeLine("");
8
- writeLine("# Zsh completion for ${r(b)}");
99
+ writeLine("# Zsh completion for ${getAppTitle(context)}");
9
100
  writeLine("");
10
101
  SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
11
102
  writeLine("");
@@ -15,5 +106,15 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
15
106
  help(\`To enable these completions, perform one of the following actions:
16
107
 
17
108
  1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
18
- 2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}export{b as ZshScriptCompletionsCommand};
109
+ 2) Save the above script to a file and source it from your shell configuration file \`); `;
110
+ } })];
111
+ }
112
+ })
113
+ ];
114
+ }
115
+ });
116
+ }
117
+
118
+ //#endregion
119
+ export { ZshScriptCompletionsCommand };
19
120
  //# sourceMappingURL=zsh-script-command.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-script-command.mjs","names":[],"sources":["../../src/components/zsh-script-command.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 } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function ZshScriptCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"script\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Script command.\" />\n <InterfaceDeclaration export name=\"ZshScriptCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions zsh script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.zsh\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n const\n name=\"scriptPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? \\`\\${path}.zsh\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Zsh script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Zsh completion script has been generated at \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\"#compdef ${bin.value} \");\n writeLine(\"#compdef _${name.value} ${bin.value}\");\n writeLine(\"\");\n writeLine(\"# Zsh completion for ${getAppTitle(context)}\");\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":"6zBAgCA,SAAS,GAAmC,CAC5C,IAAO,EAAA,GAAA,CACA,EAAA,MAAA,EAAA,EAAA,CAAA,CACL,EAAA,MAAA,EAAA,EAAA,MAAA,CAAA,CACA,OAAO,EAAkB,EAAgB,CAC3C,IAAQ,MAAC,CACH,OAAG,EAAY,EAAO,UAAY,cAAA,MAAA,SAAA,aAAA,EAExC,QAAa,gBAEX,YAAA,CAAA,OAAA,CACI,mBAAmB,CAAA,WAAc,YAAW,CAChD,YAAA,CAAA,oBAAA,4BAAA,CACF,CACE,eAAgB,CAAA,QAAA,6CAEhB,CACA,IAAM,UAAO,aAEP,QAAC,oDACJ,CAAA,CAAA,EAAA,EAAA,CACC,OAAM,GACJ,KAAA,8BACA,IAAC,UAAY,CACZ,MAAI,CAAA,EAAA,EAAA,CACJ,QAAO,6LACP,IAAO,UAAG,CACZ,OAAA,EAAA,EAAA,CACQ,IAAA,MAAA,CACG,OAAK,EAAA,SAEP,aAAc,GAClB,CAAA,EAEN,CAAA,CAAA,EAAgB,EAAA,CACd,KAAU,UACV,SAAA,GACI,KAAC,UACN,CAAA,CAAA,EAEA,CAAC,CAAE,EAAC,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACH,QAAS,8DACV,CAAC,CAAE,EAAgB,EAAK,CACvB,OAAG,GACH,QAAO,GACP,MAAC,GACD,KAAA,UACD,IAAA,YAAS,CACT,MAAM,CAAA,CACN,KAAA,UACC,KAAA,8BACA,QAAA,KACA,CAAA,CACI,KAAE,OACN,KAAU,SACR,QAAA,IAAA,EAAA,MAAA,mBACC,CAAC,EAEJ,IAAI,UAAW,CACb,MAAC,CAAA,EAAA,EAAA,CACD,UAAA,CAAA,2BACE,IAAI,UAAQ,CACZ,MAAO,CAAA,EAAO,EAAA,CACd,MAAa,GACf,KAAA,aACA,KAAA,SACD,YAAY,CAAW,iDACrB,CAAA,CAAA,MAAA,CAAA,qEAAA,EAAA,EAAA,CAAA;;wBAEO,EAAU,EAAA,CAAA,wEAAA,CAAA,EAEjB,CAAC,CAAA,EAAmB,EAAa,CACjC,IAAA,UAAA,CACA,MAAU,EAAC;;kCAEE,EAAW,MAAA;mCACrB,EAAA,MAAA,GAAA,EAAA,MAAA;;8CAEO,EAAA,EAAA,CAAA;;;;;;;;;;4GAcd,CAAC,CAAC,EAEN,CAAC"}
1
+ {"version":3,"file":"zsh-script-command.mjs","names":[],"sources":["../../src/components/zsh-script-command.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 } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function ZshScriptCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"script\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Script command.\" />\n <InterfaceDeclaration export name=\"ZshScriptCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions zsh script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.zsh\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n const\n name=\"scriptPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? \\`\\${path}.zsh\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Zsh script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Zsh completion script has been generated at \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\"#compdef ${bin.value} \");\n writeLine(\"#compdef _${name.value} ${bin.value}\");\n writeLine(\"\");\n writeLine(\"# Zsh completion for ${getAppTitle(context)}\");\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAS,8BAAmC;CAC5C,MAAO,UAAA,eAAA;CACL,MAAK,MAAA,eAAA,UAAA,QAAA,CAAA;CACL,MAAA,OAAA,eAAA,UAAA,IAAA,MAAA,CAAA;AACA,QAAO,gBAAkB,gBAAgB;EAC3C,IAAQ,OAAC;AACH,UAAG,UAAY,QAAO,WAAY,eAAA,OAAA,UAAA,aAAA;;EAExC,SAAa;;GAEX,aAAA,CAAA,OAAA;GACI,oBAAmB,CAAA,YAAc,YAAW;GAChD,aAAA,CAAA,qBAAA,4BAAA;GACF;EACE,gBAAgB;;;;;;KAEhB;EACA,IAAM,WAAO;;+BAEP,SAAC,qDACJ,CAAA;IAAA,gBAAA,sBAAA;KACC,UAAM;KACJ,MAAA;KACA,IAAC,WAAY;AACZ,aAAI,CAAA,gBAAA,SAAA;OACJ,SAAO;OACP,IAAO,WAAG;AACZ,eAAA,gBAAA,qBAAA;SACQ,IAAA,OAAA;AACG,iBAAK,eAAA;;SAEP,cAAc;SAClB,CAAA;;OAEN,CAAA,EAAA,gBAAgB,mBAAA;OACd,MAAU;OACV,UAAA;OACI,MAAC;OACN,CAAA,CAAA;;KAEA,CAAC;IAAE,gBAAC,SAAA,EAAA,CAAA;IAAA,gBAAA,SAAA,EACH,SAAS,+DACV,CAAC;IAAE,gBAAgB,qBAAK;KACvB,UAAG;KACH,WAAO;KACP,OAAC;KACD,MAAA;KACD,IAAA,aAAS;AACT,aAAM,CAAA;OACN,MAAA;OACC,MAAA;OACA,SAAA;OACA,EAAA;OACI,MAAE;OACN,MAAU;OACR,SAAA,IAAA,IAAA,MAAA;OACC,CAAC;;KAEJ,IAAI,WAAW;AACb,aAAC,CAAA,gBAAA,aAAA;OACD,WAAA,IAAA;OACE,IAAI,WAAQ;AACZ,eAAO,CAAA,gBAAO,gBAAA;SACd,SAAa;SACf,MAAA;SACA,MAAA;SACD,aAAY,IAAW;SACrB,CAAA,EAAA,WAAA,IAAA,qEAAA,YAAA,QAAA,CAAA;;wBAEO,YAAU,QAAA,CAAA,wEAAA,CAAA;;OAEjB,CAAC,EAAA,gBAAmB,YAAa,EACjC,IAAA,WAAA;AACA,cAAU,IAAC;;kCAEE,IAAW,MAAA;mCACrB,KAAA,MAAA,GAAA,IAAA,MAAA;;8CAEO,YAAA,QAAA,CAAA;;;;;;;;;;;;;KAcd,CAAC;IAAC;;EAEN,CAAC"}
@@ -1,35 +1,83 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../helpers/complete-command.cjs`),t=require(`../helpers/completion-directive-constants.cjs`);require(`../helpers/index.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@shell-shock/core/plugin-utils`),i=require(`@alloy-js/core`),a=require(`@alloy-js/typescript`),o=require(`@powerlines/plugin-alloy/core`),s=require(`@powerlines/plugin-alloy/core/contexts/context`),c=require(`@powerlines/plugin-alloy/typescript`),l=require(`@stryke/path`),u=require(`@stryke/string-format/snake-case`);function d(){let d=(0,s.usePowerlines)(),f=(0,i.computed)(()=>(0,r.getAppBin)(d)),p=(0,i.computed)(()=>(0,u.snakeCase)(f.value));return(0,n.createComponent)(c.TypescriptFile,{get path(){return(0,l.joinPaths)(d.entryPath,`completions`,`zsh`,`shared.ts`)},builtinImports:{console:[`white`,`green`,`red`,`bold`,`cyan`,`gray`,`magenta`,`magentaBright`,`greenBright`,`redBright`,`cyanBright`,`dim`]},get children(){return[(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(a.VarDeclaration,{const:!0,export:!0,name:`SHELL_COMPLETIONS`,get initializer(){return i.code` \`__${p.value}_debug() {
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_helpers_complete_command = require('../helpers/complete-command.cjs');
3
+ const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
4
+ require('../helpers/index.cjs');
5
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
6
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
7
+ let _alloy_js_core = require("@alloy-js/core");
8
+ let _alloy_js_typescript = require("@alloy-js/typescript");
9
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
10
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
11
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
12
+ let _stryke_path = require("@stryke/path");
13
+ let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
14
+
15
+ //#region src/components/zsh-shared.tsx
16
+ /**
17
+ * The Zsh Completions generation for the Shell Shock project.
18
+ */
19
+ function ZshCompletionsShared() {
20
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
21
+ const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
22
+ const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_snake_case.snakeCase)(bin.value));
23
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
24
+ get path() {
25
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "shared.ts");
26
+ },
27
+ builtinImports: { console: [
28
+ "white",
29
+ "green",
30
+ "red",
31
+ "bold",
32
+ "cyan",
33
+ "gray",
34
+ "magenta",
35
+ "magentaBright",
36
+ "greenBright",
37
+ "redBright",
38
+ "cyanBright",
39
+ "dim"
40
+ ] },
41
+ get children() {
42
+ return [
43
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
44
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
45
+ "const": true,
46
+ "export": true,
47
+ name: "SHELL_COMPLETIONS",
48
+ get initializer() {
49
+ return _alloy_js_core.code` \`__${name.value}_debug() {
2
50
  local file="$BASH_COMP_DEBUG_FILE"
3
51
  if [[ -n \\\${file} ]]; then
4
52
  echo "$*" >> "\\\${file}"
5
53
  fi
6
54
  }
7
55
 
8
- _${p.value}() {
9
- local shellCompDirectiveError=${t.CompletionDirective.CompletionDirectiveError}
10
- local shellCompDirectiveNoSpace=${t.CompletionDirective.CompletionDirectiveNoSpace}
11
- local shellCompDirectiveNoFileComp=${t.CompletionDirective.CompletionDirectiveNoFileComp}
12
- local shellCompDirectiveFilterFileExt=${t.CompletionDirective.CompletionDirectiveFilterFileExt}
13
- local shellCompDirectiveFilterDirs=${t.CompletionDirective.CompletionDirectiveFilterDirs}
14
- local shellCompDirectiveKeepOrder=${t.CompletionDirective.CompletionDirectiveKeepOrder}
56
+ _${name.value}() {
57
+ local shellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
58
+ local shellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
59
+ local shellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
60
+ local shellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
61
+ local shellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
62
+ local shellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
15
63
 
16
64
  local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
17
65
  local -a completions
18
66
 
19
- __${p.value}_debug "\\n========= starting completion logic =========="
20
- __${p.value}_debug "CURRENT: \\\${CURRENT}, words[*]: \\\${words[*]}"
67
+ __${name.value}_debug "\\n========= starting completion logic =========="
68
+ __${name.value}_debug "CURRENT: \\\${CURRENT}, words[*]: \\\${words[*]}"
21
69
 
22
70
  # The user could have moved the cursor backwards on the command-line.
23
71
  # We need to trigger completion from the $CURRENT location, so we need
24
72
  # to truncate the command-line ($words) up to the $CURRENT location.
25
73
  # (We cannot use $CURSOR as its value does not work when a command is an alias.)
26
74
  words=( "\\\${=words[1,CURRENT]}" )
27
- __${p.value}_debug "Truncated words[*]: \\\${words[*]},"
75
+ __${name.value}_debug "Truncated words[*]: \\\${words[*]},"
28
76
 
29
77
  lastParam=\\\${words[-1]}
30
78
  lastChar=\\\${lastParam[-1]}
31
- __${p.value}_debug "lastParam: \\\${lastParam}, lastChar: \\\${lastChar}"
32
- # For zsh, when completing a flag with an = (e.g., ${f.value} -n=<TAB>)
79
+ __${name.value}_debug "lastParam: \\\${lastParam}, lastChar: \\\${lastChar}"
80
+ # For zsh, when completing a flag with an = (e.g., ${bin.value} -n=<TAB>)
33
81
  # completions must be prefixed with the flag
34
82
  setopt local_options BASH_REMATCH
35
83
  if [[ "\\\${lastParam}" =~ '-.*=' ]]; then
@@ -42,7 +90,7 @@ _${p.value}() {
42
90
  if [ "\\\${lastChar}" = "" ]; then
43
91
  # If the last parameter is complete (there is a space following it)
44
92
  # We add an extra empty parameter so we can indicate this to the go completion code.
45
- __${p.value}_debug "Adding extra empty parameter"
93
+ __${name.value}_debug "Adding extra empty parameter"
46
94
  args_to_quote+=("")
47
95
  fi
48
96
 
@@ -50,20 +98,20 @@ _${p.value}() {
50
98
  local quoted_args=("\\\${(@q)args_to_quote}")
51
99
 
52
100
  # Join the main command and the quoted arguments into a single string for eval
53
- requestComp="${e.EXEC_COMMAND} complete -- \\\${quoted_args[*]}"
101
+ requestComp="${require_helpers_complete_command.EXEC_COMMAND} complete -- \\\${quoted_args[*]}"
54
102
 
55
- __${p.value}_debug "About to call: eval \\\${requestComp}"
103
+ __${name.value}_debug "About to call: eval \\\${requestComp}"
56
104
 
57
105
  # Use eval to handle any environment variables and such
58
106
  out=$(eval \\\${requestComp} 2>/dev/null)
59
- __${p.value}_debug "completion output: \\\${out}"
107
+ __${name.value}_debug "completion output: \\\${out}"
60
108
 
61
109
  # Extract the directive integer following a : from the last line
62
110
  local lastLine
63
111
  while IFS='\n' read -r line; do
64
112
  lastLine=\\\${line}
65
113
  done < <(printf "%s\n" "\\\${out[@]}")
66
- __${p.value}_debug "last line: \\\${lastLine}"
114
+ __${name.value}_debug "last line: \\\${lastLine}"
67
115
 
68
116
  if [ "\\\${lastLine[1]}" = : ]; then
69
117
  directive=\\\${lastLine[2,-1]}
@@ -73,16 +121,16 @@ _${p.value}() {
73
121
  out=\\\${out[1,-$suffix]}
74
122
  else
75
123
  # There is no directive specified. Leave $out as is.
76
- __${p.value}_debug "No directive found. Setting to default"
124
+ __${name.value}_debug "No directive found. Setting to default"
77
125
  directive=0
78
126
  fi
79
127
 
80
- __${p.value}_debug "directive: \\\${directive}"
81
- __${p.value}_debug "completions: \\\${out}"
82
- __${p.value}_debug "flagPrefix: \\\${flagPrefix}"
128
+ __${name.value}_debug "directive: \\\${directive}"
129
+ __${name.value}_debug "completions: \\\${out}"
130
+ __${name.value}_debug "flagPrefix: \\\${flagPrefix}"
83
131
 
84
132
  if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
85
- __${p.value}_debug "Completion received error. Ignoring completions."
133
+ __${name.value}_debug "Completion received error. Ignoring completions."
86
134
  return
87
135
  fi
88
136
 
@@ -93,11 +141,11 @@ _${p.value}() {
93
141
  while IFS='\n' read -r comp; do
94
142
  # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
95
143
  if [ "\\\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
96
- __${p.value}_debug "ActiveHelp found: $comp"
144
+ __${name.value}_debug "ActiveHelp found: $comp"
97
145
  comp="\\\${comp[$startIndex,-1]}"
98
146
  if [ -n "$comp" ]; then
99
147
  compadd -x "\\\${comp}"
100
- __${p.value}_debug "ActiveHelp will need delimiter"
148
+ __${name.value}_debug "ActiveHelp will need delimiter"
101
149
  hasActiveHelp=1
102
150
  fi
103
151
  continue
@@ -113,7 +161,7 @@ _${p.value}() {
113
161
  local tab="$(printf '\\t')"
114
162
  comp=\\\${comp//$tab/:}
115
163
 
116
- __${p.value}_debug "Adding completion: \\\${comp}"
164
+ __${name.value}_debug "Adding completion: \\\${comp}"
117
165
  completions+=\\\${comp}
118
166
  lastComp=$comp
119
167
  fi
@@ -124,19 +172,19 @@ _${p.value}() {
124
172
  # - file completion will be performed (so there will be choices after the activeHelp)
125
173
  if [ $hasActiveHelp -eq 1 ]; then
126
174
  if [ \\\${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
127
- __${p.value}_debug "Adding activeHelp delimiter"
175
+ __${name.value}_debug "Adding activeHelp delimiter"
128
176
  compadd -x "--"
129
177
  hasActiveHelp=0
130
178
  fi
131
179
  fi
132
180
 
133
181
  if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
134
- __${p.value}_debug "Activating nospace."
182
+ __${name.value}_debug "Activating nospace."
135
183
  noSpace="-S ''"
136
184
  fi
137
185
 
138
186
  if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
139
- __${p.value}_debug "Activating keep order."
187
+ __${name.value}_debug "Activating keep order."
140
188
  keepOrder="-V"
141
189
  fi
142
190
 
@@ -153,17 +201,17 @@ _${p.value}() {
153
201
  done
154
202
  filteringCmd+=" \\\${flagPrefix}"
155
203
 
156
- __${p.value}_debug "File filtering command: $filteringCmd"
204
+ __${name.value}_debug "File filtering command: $filteringCmd"
157
205
  _arguments '*:filename:'"$filteringCmd"
158
206
  elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
159
207
  # File completion for directories only
160
208
  local subdir
161
209
  subdir="\\\${completions[1]}"
162
210
  if [ -n "$subdir" ]; then
163
- __${p.value}_debug "Listing directories in $subdir"
211
+ __${name.value}_debug "Listing directories in $subdir"
164
212
  pushd "\\\${subdir}" >/dev/null 2>&1
165
213
  else
166
- __${p.value}_debug "Listing directories in ."
214
+ __${name.value}_debug "Listing directories in ."
167
215
  fi
168
216
 
169
217
  local result
@@ -174,17 +222,17 @@ _${p.value}() {
174
222
  fi
175
223
  return $result
176
224
  else
177
- __${p.value}_debug "Calling _describe"
225
+ __${name.value}_debug "Calling _describe"
178
226
  if eval _describe $keepOrder "completions" completions -Q \\\${flagPrefix} \\\${noSpace}; then
179
- __${p.value}_debug "_describe found some completions"
227
+ __${name.value}_debug "_describe found some completions"
180
228
 
181
229
  # Return the success of having called _describe
182
230
  return 0
183
231
  else
184
- __${p.value}_debug "_describe did not find completions."
185
- __${p.value}_debug "Checking if we should do file completion."
232
+ __${name.value}_debug "_describe did not find completions."
233
+ __${name.value}_debug "Checking if we should do file completion."
186
234
  if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
187
- __${p.value}_debug "deactivating file completion"
235
+ __${name.value}_debug "deactivating file completion"
188
236
 
189
237
  # Return 0 to indicate completion is finished and prevent zsh from
190
238
  # trying other completion algorithms (which could cause hanging).
@@ -192,7 +240,7 @@ _${p.value}() {
192
240
  return 0
193
241
  else
194
242
  # Perform file completion
195
- __${p.value}_debug "Activating file completion"
243
+ __${name.value}_debug "Activating file completion"
196
244
 
197
245
  # We must return the result of this command, so it must be the
198
246
  # last command, or else we must store its result to return it.
@@ -203,10 +251,18 @@ _${p.value}() {
203
251
  }
204
252
 
205
253
  # don't run the completion function when being sourced or eval-ed
206
- if [ "\\\${funcstack[1]}" = "_${p.value}" ]; then
207
- _${p.value}
254
+ if [ "\\\${funcstack[1]}" = "_${name.value}" ]; then
255
+ _${name.value}
208
256
  fi
209
- \`; `}}),(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(a.VarDeclaration,{export:!0,const:!0,name:`SHELL_COMPLETIONS_DISPLAY`,initializer:i.code` SHELL_COMPLETIONS.split("\\n").map(line => {
257
+ \`; `;
258
+ }
259
+ }),
260
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
261
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
262
+ "export": true,
263
+ "const": true,
264
+ name: "SHELL_COMPLETIONS_DISPLAY",
265
+ initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
210
266
  if (!line.trim()) {
211
267
  return "";
212
268
  }
@@ -227,4 +283,12 @@ fi
227
283
  .replaceAll(/__\\w/g, bold(magentaBright("$&")))
228
284
  .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
229
285
 
230
- }).join("\\n"); `})]}})}exports.ZshCompletionsShared=d;
286
+ }).join("\\n"); `
287
+ })
288
+ ];
289
+ }
290
+ });
291
+ }
292
+
293
+ //#endregion
294
+ exports.ZshCompletionsShared = ZshCompletionsShared;