@shell-shock/plugin-completions 0.2.23 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/bash-config-command.cjs +132 -0
- package/dist/components/bash-config-command.d.cts +10 -0
- package/dist/components/bash-config-command.d.cts.map +1 -0
- package/dist/components/bash-config-command.d.mts +10 -0
- package/dist/components/bash-config-command.d.mts.map +1 -0
- package/dist/components/bash-config-command.mjs +132 -0
- package/dist/components/bash-config-command.mjs.map +1 -0
- package/dist/components/bash-script-command.cjs +106 -0
- package/dist/components/bash-script-command.d.cts +10 -0
- package/dist/components/bash-script-command.d.cts.map +1 -0
- package/dist/components/bash-script-command.d.mts +10 -0
- package/dist/components/bash-script-command.d.mts.map +1 -0
- package/dist/components/bash-script-command.mjs +106 -0
- package/dist/components/bash-script-command.mjs.map +1 -0
- package/dist/components/bash-shared.cjs +172 -0
- package/dist/components/bash-shared.d.cts +10 -0
- package/dist/components/bash-shared.d.cts.map +1 -0
- package/dist/components/bash-shared.d.mts +10 -0
- package/dist/components/bash-shared.d.mts.map +1 -0
- package/dist/components/bash-shared.mjs +172 -0
- package/dist/components/bash-shared.mjs.map +1 -0
- package/dist/components/fish-config-command.cjs +132 -0
- package/dist/components/fish-config-command.d.cts +10 -0
- package/dist/components/fish-config-command.d.cts.map +1 -0
- package/dist/components/fish-config-command.d.mts +10 -0
- package/dist/components/fish-config-command.d.mts.map +1 -0
- package/dist/components/fish-config-command.mjs +132 -0
- package/dist/components/fish-config-command.mjs.map +1 -0
- package/dist/components/fish-script-command.cjs +106 -0
- package/dist/components/fish-script-command.d.cts +10 -0
- package/dist/components/fish-script-command.d.cts.map +1 -0
- package/dist/components/fish-script-command.d.mts +10 -0
- package/dist/components/fish-script-command.d.mts.map +1 -0
- package/dist/components/fish-script-command.mjs +106 -0
- package/dist/components/fish-script-command.mjs.map +1 -0
- package/dist/components/fish-shared.cjs +303 -0
- package/dist/components/fish-shared.d.cts +10 -0
- package/dist/components/fish-shared.d.cts.map +1 -0
- package/dist/components/fish-shared.d.mts +10 -0
- package/dist/components/fish-shared.d.mts.map +1 -0
- package/dist/components/fish-shared.mjs +303 -0
- package/dist/components/fish-shared.mjs.map +1 -0
- package/dist/components/index.cjs +24 -8
- package/dist/components/index.d.cts +13 -5
- package/dist/components/index.d.mts +13 -5
- package/dist/components/index.mjs +13 -5
- package/dist/components/powershell-config-command.cjs +128 -0
- package/dist/components/powershell-config-command.d.cts +7 -0
- package/dist/components/powershell-config-command.d.cts.map +1 -0
- package/dist/components/powershell-config-command.d.mts +7 -0
- package/dist/components/powershell-config-command.d.mts.map +1 -0
- package/dist/components/powershell-config-command.mjs +128 -0
- package/dist/components/powershell-config-command.mjs.map +1 -0
- package/dist/components/powershell-script-command.cjs +106 -0
- package/dist/components/powershell-script-command.d.cts +10 -0
- package/dist/components/powershell-script-command.d.cts.map +1 -0
- package/dist/components/powershell-script-command.d.mts +10 -0
- package/dist/components/powershell-script-command.d.mts.map +1 -0
- package/dist/components/powershell-script-command.mjs +106 -0
- package/dist/components/powershell-script-command.mjs.map +1 -0
- package/dist/components/powershell-shared.cjs +319 -0
- package/dist/components/powershell-shared.d.cts +10 -0
- package/dist/components/powershell-shared.d.cts.map +1 -0
- package/dist/components/powershell-shared.d.mts +10 -0
- package/dist/components/powershell-shared.d.mts.map +1 -0
- package/dist/components/{powershell-command.mjs → powershell-shared.mjs} +81 -181
- package/dist/components/powershell-shared.mjs.map +1 -0
- package/dist/components/zsh-config-command.cjs +132 -0
- package/dist/components/zsh-config-command.d.cts +10 -0
- package/dist/components/zsh-config-command.d.cts.map +1 -0
- package/dist/components/zsh-config-command.d.mts +10 -0
- package/dist/components/zsh-config-command.d.mts.map +1 -0
- package/dist/components/zsh-config-command.mjs +132 -0
- package/dist/components/zsh-config-command.mjs.map +1 -0
- package/dist/components/zsh-script-command.cjs +111 -0
- package/dist/components/zsh-script-command.d.cts +10 -0
- package/dist/components/zsh-script-command.d.cts.map +1 -0
- package/dist/components/zsh-script-command.d.mts +10 -0
- package/dist/components/zsh-script-command.d.mts.map +1 -0
- package/dist/components/zsh-script-command.mjs +111 -0
- package/dist/components/zsh-script-command.mjs.map +1 -0
- package/dist/components/zsh-shared.cjs +281 -0
- package/dist/components/zsh-shared.d.cts +10 -0
- package/dist/components/zsh-shared.d.cts.map +1 -0
- package/dist/components/zsh-shared.d.mts +10 -0
- package/dist/components/zsh-shared.d.mts.map +1 -0
- package/dist/components/zsh-shared.mjs +281 -0
- package/dist/components/zsh-shared.mjs.map +1 -0
- package/dist/helpers/complete-command.cjs +2 -7
- package/dist/helpers/complete-command.d.cts +2 -2
- package/dist/helpers/complete-command.d.cts.map +1 -1
- package/dist/helpers/complete-command.d.mts +2 -2
- package/dist/helpers/complete-command.d.mts.map +1 -1
- package/dist/helpers/complete-command.mjs +2 -7
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/index.cjs +245 -59
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +246 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +148 -37
- package/dist/components/bash-command.cjs +0 -273
- package/dist/components/bash-command.d.cts +0 -10
- package/dist/components/bash-command.d.cts.map +0 -1
- package/dist/components/bash-command.d.mts +0 -10
- package/dist/components/bash-command.d.mts.map +0 -1
- package/dist/components/bash-command.mjs +0 -273
- package/dist/components/bash-command.mjs.map +0 -1
- package/dist/components/fish-command.cjs +0 -403
- package/dist/components/fish-command.d.cts +0 -10
- package/dist/components/fish-command.d.cts.map +0 -1
- package/dist/components/fish-command.d.mts +0 -10
- package/dist/components/fish-command.d.mts.map +0 -1
- package/dist/components/fish-command.mjs +0 -403
- package/dist/components/fish-command.mjs.map +0 -1
- package/dist/components/powershell-command.cjs +0 -419
- package/dist/components/powershell-command.d.cts +0 -10
- package/dist/components/powershell-command.d.cts.map +0 -1
- package/dist/components/powershell-command.d.mts +0 -10
- package/dist/components/powershell-command.d.mts.map +0 -1
- package/dist/components/powershell-command.mjs.map +0 -1
- package/dist/components/zsh-command.cjs +0 -384
- package/dist/components/zsh-command.d.cts +0 -10
- package/dist/components/zsh-command.d.cts.map +0 -1
- package/dist/components/zsh-command.d.mts +0 -10
- package/dist/components/zsh-command.d.mts.map +0 -1
- package/dist/components/zsh-command.mjs +0 -384
- package/dist/components/zsh-command.mjs.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
|
|
12
|
+
//#region src/components/powershell-script-command.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
|
|
15
|
+
*/
|
|
16
|
+
function PowerShellScriptCompletionsCommand() {
|
|
17
|
+
const context = usePowerlines();
|
|
18
|
+
const bin = computed(() => getAppBin(context));
|
|
19
|
+
return createComponent(TypescriptFile, {
|
|
20
|
+
get path() {
|
|
21
|
+
return joinPaths(context.entryPath, "completions", "powershell", "script", "command.ts");
|
|
22
|
+
},
|
|
23
|
+
imports: {
|
|
24
|
+
"node:os": "os",
|
|
25
|
+
"node:path": ["join"],
|
|
26
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
28
|
+
},
|
|
29
|
+
builtinImports: { "shell-shock:console": [
|
|
30
|
+
"colors",
|
|
31
|
+
"writeLine",
|
|
32
|
+
"success",
|
|
33
|
+
"warn"
|
|
34
|
+
] },
|
|
35
|
+
get children() {
|
|
36
|
+
return [
|
|
37
|
+
createComponent(TSDoc$1, { heading: "Options for the PowerShell Completions - Script command." }),
|
|
38
|
+
createComponent(InterfaceDeclaration, {
|
|
39
|
+
"export": true,
|
|
40
|
+
name: "PowerShellScriptCompletionsOptions",
|
|
41
|
+
get children() {
|
|
42
|
+
return [createComponent(TSDoc$1, {
|
|
43
|
+
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.",
|
|
44
|
+
get children() {
|
|
45
|
+
return createComponent(TSDocDefaultValue$1, {
|
|
46
|
+
get type() {
|
|
47
|
+
return ReflectionKind.boolean;
|
|
48
|
+
},
|
|
49
|
+
defaultValue: false
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}), createComponent(InterfaceMember$1, {
|
|
53
|
+
name: "display",
|
|
54
|
+
optional: true,
|
|
55
|
+
type: "boolean"
|
|
56
|
+
})];
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
createComponent(Spacing, {}),
|
|
60
|
+
createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions powershell script\\` command." }),
|
|
61
|
+
createComponent(FunctionDeclaration, {
|
|
62
|
+
"export": true,
|
|
63
|
+
"default": true,
|
|
64
|
+
async: true,
|
|
65
|
+
name: "handler",
|
|
66
|
+
get parameters() {
|
|
67
|
+
return [{
|
|
68
|
+
name: "options",
|
|
69
|
+
type: "PowerShellScriptCompletionsOptions",
|
|
70
|
+
default: "{}"
|
|
71
|
+
}, {
|
|
72
|
+
name: "path",
|
|
73
|
+
type: "string",
|
|
74
|
+
default: `"${bin.value}-completions.ps1"`
|
|
75
|
+
}];
|
|
76
|
+
},
|
|
77
|
+
get children() {
|
|
78
|
+
return [createComponent(IfStatement, {
|
|
79
|
+
condition: code`options.display !== true`,
|
|
80
|
+
get children() {
|
|
81
|
+
return [createComponent(VarDeclaration, {
|
|
82
|
+
"const": true,
|
|
83
|
+
name: "scriptPath",
|
|
84
|
+
type: "string",
|
|
85
|
+
initializer: code` path.includes(".") ? \`\${path}.ps1\` : path;`
|
|
86
|
+
}), memo(() => code`await writeFile(scriptPath, \`# PowerShell script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
87
|
+
|
|
88
|
+
success(\`${getAppTitle(context)} PowerShell completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
|
|
89
|
+
}
|
|
90
|
+
}), createComponent(ElseClause, { get children() {
|
|
91
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
92
|
+
writeLine(\`# PowerShell completions for ${getAppTitle(context)}\`);
|
|
93
|
+
writeLine("");
|
|
94
|
+
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
95
|
+
writeLine(" ------------------------------------------------- ");`;
|
|
96
|
+
} })];
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { PowerShellScriptCompletionsCommand };
|
|
106
|
+
//# sourceMappingURL=powershell-script-command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powershell-script-command.mjs","names":[],"sources":["../../src/components/powershell-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 type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function PowerShellScriptCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\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 \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the PowerShell Completions - Script command.\" />\n <InterfaceDeclaration export name=\"PowerShellScriptCompletionsOptions\">\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 powershell script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"PowerShellScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.ps1\"`\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}.ps1\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# PowerShell script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} PowerShell completion script has been generated at \\${colors.bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`# PowerShell completions for ${getAppTitle(context)}\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAO,qCAAA;CACL,MAAK,UAAA,eAAA;CACL,MAAA,MAAA,eAAA,UAAA,QAAA,CAAA;AACA,QAAO,gBAAkB,gBAAgB;EAC3C,IAAQ,OAAC;AACH,UAAG,UAAY,QAAO,WAAY,eAAA,cAAA,UAAA,aAAA;;;GAGtC,WAAA;GACI,aAAY,CAAA,OAAA;GAChB,oBAAA,CAAA,YAAA,YAAA;GACI,aAAU,CAAA,qBAAA,4BAAqC;GACnD;oBAEA,uBAA2B;GAAA;GAAU;GAAS;GAAA;GAAA;EAE9C,IAAM,WAAC;AACJ,UAAA;IAAA,gBAAA,SAAA,EACC,SAAM,4DACL,CAAC;IAAA,gBAAiB,sBAAA;KACjB,UAAC;KACD,MAAC;KACD,IAAC,WAAO;AACP,aAAQ,CAAA,gBAAE,SAAA;OACZ,SAAA;OACD,IAAS,WAAA;AACD,eAAM,gBAAG,qBAAA;SACT,IAAM,OAAO;AACV,iBAAQ,eAAe;;SAEjC,cAAA;SACD,CAAA;;OAEE,CAAA,EAAA,gBAAA,mBAAA;OACI,MAAC;OACN,UAAA;OACE,MAAM;OACJ,CAAA,CAAA;;KAEJ,CAAC;IAAE,gBAAgB,SAAK,EAAA,CAAA;IAAA,gBAAA,SAAA,EACvB,SAAG,sEACJ,CAAC;IAAE,gBAAK,qBAAA;KACP,UAAC;KACD,WAAA;KACD,OAAQ;KACR,MAAM;KACN,IAAA,aAAA;AACC,aAAA,CAAA;OACA,MAAA;OACA,MAAA;OACI,SAAS;OACb,EAAA;OACE,MAAA;OACE,MAAM;OACN,SAAO,IAAA,IAAA,MAAA;OACR,CAAC;;KAEJ,IAAE,WAAA;AACA,aAAO,CAAC,gBAAM,aAAA;OACZ,WAAO,IAAO;OACd,IAAA,WAAa;AACf,eAAA,CAAA,gBAAA,gBAAA;SACA,SAAA;SACD,MAAY;SACV,MAAA;SACC,aAAA,IAAA;SACA,CAAI,EAAE,WAAU,IAAA,4EAAA,YAAA,QAAA,CAAA;;wBAEJ,YAAY,QAAQ,CAAC,sFAAgC,CAAA;;OAElE,CAAA,EAAA,gBAAqB,YAAY;AAEhC,cAAS,IAAG;uDACV,YAAA,QAAA,CAAA;;;;SAKH,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
|
|
@@ -0,0 +1,319 @@
|
|
|
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_camel_case = require("@stryke/string-format/camel-case");
|
|
14
|
+
|
|
15
|
+
//#region src/components/powershell-shared.tsx
|
|
16
|
+
/**
|
|
17
|
+
* The PowerShell Completions generation for the Shell Shock project.
|
|
18
|
+
*/
|
|
19
|
+
function PowerShellCompletionsShared() {
|
|
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_camel_case.camelCase)(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", "powershell", "shared.ts");
|
|
26
|
+
},
|
|
27
|
+
builtinImports: { console: ["colors"] },
|
|
28
|
+
get children() {
|
|
29
|
+
return [
|
|
30
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
31
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
32
|
+
"const": true,
|
|
33
|
+
"export": true,
|
|
34
|
+
name: "SHELL_COMPLETIONS",
|
|
35
|
+
get initializer() {
|
|
36
|
+
return _alloy_js_core.code` \`# powershell completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}
|
|
37
|
+
|
|
38
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
39
|
+
function __${name.value}_debug {
|
|
40
|
+
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
41
|
+
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
filter __${name.value}_escapeStringWithSpecialChars {
|
|
46
|
+
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\\\`$&'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[scriptblock]$__${name.value}CompleterBlock = {
|
|
50
|
+
param(
|
|
51
|
+
$WordToComplete,
|
|
52
|
+
$CommandAst,
|
|
53
|
+
$CursorPosition
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Get the current command-line and convert into a string
|
|
57
|
+
$Command = $CommandAst.CommandElements
|
|
58
|
+
$Command = "$Command"
|
|
59
|
+
|
|
60
|
+
__${name.value}_debug ""
|
|
61
|
+
__${name.value}_debug "========= starting completion logic =========="
|
|
62
|
+
__${name.value}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
63
|
+
|
|
64
|
+
# The user could have moved the cursor backwards on the command-line.
|
|
65
|
+
# We need to trigger completion from the $CursorPosition location, so we need
|
|
66
|
+
# to truncate the command-line ($Command) up to the $CursorPosition location.
|
|
67
|
+
# Make sure the $Command is longer then the $CursorPosition before we truncate.
|
|
68
|
+
# This happens because the $Command does not include the last space.
|
|
69
|
+
if ($Command.Length -gt $CursorPosition) {
|
|
70
|
+
$Command = $Command.Substring(0, $CursorPosition)
|
|
71
|
+
}
|
|
72
|
+
__${name.value}_debug "Truncated command: $Command"
|
|
73
|
+
|
|
74
|
+
$ShellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
|
|
75
|
+
$ShellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
|
|
76
|
+
$ShellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
|
|
77
|
+
$ShellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
78
|
+
$ShellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
|
|
79
|
+
$ShellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
|
|
80
|
+
|
|
81
|
+
# Prepare the command to request completions for the program.
|
|
82
|
+
# Split the command at the first space to separate the program and arguments.
|
|
83
|
+
$Program, $Arguments = $Command.Split(" ", 2)
|
|
84
|
+
|
|
85
|
+
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
86
|
+
__${name.value}_debug "QuotedArgs: $QuotedArgs"
|
|
87
|
+
|
|
88
|
+
$RequestComp = "& ${require_helpers_complete_command.EXEC_COMMAND} complete '--' $QuotedArgs"
|
|
89
|
+
__${name.value}_debug "RequestComp: $RequestComp"
|
|
90
|
+
|
|
91
|
+
# we cannot use $WordToComplete because it
|
|
92
|
+
# has the wrong values if the cursor was moved
|
|
93
|
+
# so use the last argument
|
|
94
|
+
if ($WordToComplete -ne "" ) {
|
|
95
|
+
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
96
|
+
}
|
|
97
|
+
__${name.value}_debug "New WordToComplete: $WordToComplete"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Check for flag with equal sign
|
|
101
|
+
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
102
|
+
if ( $IsEqualFlag ) {
|
|
103
|
+
__${name.value}_debug "Completing equal sign flag"
|
|
104
|
+
# Remove the flag part
|
|
105
|
+
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
109
|
+
# If the last parameter is complete (there is a space following it)
|
|
110
|
+
# We add an extra empty parameter so we can indicate this to the go method.
|
|
111
|
+
__${name.value}_debug "Adding extra empty parameter"
|
|
112
|
+
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
113
|
+
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
114
|
+
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
115
|
+
($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
|
|
116
|
+
(($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
|
|
117
|
+
$PSNativeCommandArgumentPassing -eq 'Legacy')) {
|
|
118
|
+
$RequestComp="$RequestComp" + ' \\\`"\\\`"'
|
|
119
|
+
} else {
|
|
120
|
+
$RequestComp = "$RequestComp" + ' ""'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
__${name.value}_debug "Calling $RequestComp"
|
|
125
|
+
# First disable ActiveHelp which is not supported for Powershell
|
|
126
|
+
$env:ActiveHelp = 0
|
|
127
|
+
|
|
128
|
+
# call the command store the output in $out and redirect stderr and stdout to null
|
|
129
|
+
# $Out is an array contains each line per element
|
|
130
|
+
Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
|
|
131
|
+
|
|
132
|
+
# get directive from last line
|
|
133
|
+
[int]$Directive = $Out[-1].TrimStart(':')
|
|
134
|
+
if ($Directive -eq "") {
|
|
135
|
+
# There is no directive specified
|
|
136
|
+
$Directive = 0
|
|
137
|
+
}
|
|
138
|
+
__${name.value}_debug "The completion directive is: $Directive"
|
|
139
|
+
|
|
140
|
+
# remove directive (last element) from out
|
|
141
|
+
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
142
|
+
__${name.value}_debug "The completions are: $Out"
|
|
143
|
+
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
144
|
+
# Error code. No completion.
|
|
145
|
+
__${name.value}_debug "Received error from custom completion go code"
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
$Longest = 0
|
|
150
|
+
[Array]$Values = $Out | ForEach-Object {
|
|
151
|
+
# Split the output in name and description
|
|
152
|
+
$Name, $Description = $_.Split("\\\`t", 2)
|
|
153
|
+
__${name.value}_debug "Name: $Name Description: $Description"
|
|
154
|
+
|
|
155
|
+
# Look for the longest completion so that we can format things nicely
|
|
156
|
+
if ($Longest -lt $Name.Length) {
|
|
157
|
+
$Longest = $Name.Length
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
# Set the description to a one space string if there is none set.
|
|
161
|
+
# This is needed because the CompletionResult does not accept an empty string as argument
|
|
162
|
+
if (-Not $Description) {
|
|
163
|
+
$Description = " "
|
|
164
|
+
}
|
|
165
|
+
@{ Name = "$Name"; Description = "$Description" }
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
$Space = " "
|
|
170
|
+
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
171
|
+
# remove the space here
|
|
172
|
+
__${name.value}_debug "ShellCompDirectiveNoSpace is called"
|
|
173
|
+
$Space = ""
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
177
|
+
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
178
|
+
__${name.value}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
179
|
+
|
|
180
|
+
# return here to prevent the completion of the extensions
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
$Values = $Values | Where-Object {
|
|
185
|
+
# filter the result
|
|
186
|
+
$_.Name -like "$WordToComplete*"
|
|
187
|
+
|
|
188
|
+
# Join the flag back if we have an equal sign flag
|
|
189
|
+
if ( $IsEqualFlag ) {
|
|
190
|
+
__${name.value}_debug "Join the equal sign flag back to the completion value"
|
|
191
|
+
$_.Name = $Flag + "=" + $_.Name
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# we sort the values in ascending order by name if keep order isn't passed
|
|
196
|
+
if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
|
|
197
|
+
$Values = $Values | Sort-Object -Property Name
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
201
|
+
__${name.value}_debug "ShellCompDirectiveNoFileComp is called"
|
|
202
|
+
|
|
203
|
+
if ($Values.Length -eq 0) {
|
|
204
|
+
# Just print an empty string here so the
|
|
205
|
+
# shell does not start to complete paths.
|
|
206
|
+
# We cannot use CompletionResult here because
|
|
207
|
+
# it does not accept an empty string as argument.
|
|
208
|
+
""
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
# Get the current mode
|
|
214
|
+
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
215
|
+
__${name.value}_debug "Mode: $Mode"
|
|
216
|
+
|
|
217
|
+
$Values | ForEach-Object {
|
|
218
|
+
|
|
219
|
+
# store temporary because switch will overwrite $_
|
|
220
|
+
$comp = $_
|
|
221
|
+
|
|
222
|
+
# PowerShell supports three different completion modes
|
|
223
|
+
# - TabCompleteNext (default windows style - on each key press the next option is displayed)
|
|
224
|
+
# - Complete (works like bash)
|
|
225
|
+
# - MenuComplete (works like zsh)
|
|
226
|
+
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
|
|
227
|
+
|
|
228
|
+
# CompletionResult Arguments:
|
|
229
|
+
# 1) CompletionText text to be used as the auto completion result
|
|
230
|
+
# 2) ListItemText text to be displayed in the suggestion list
|
|
231
|
+
# 3) ResultType type of completion result
|
|
232
|
+
# 4) ToolTip text for the tooltip with details about the object
|
|
233
|
+
|
|
234
|
+
switch ($Mode) {
|
|
235
|
+
|
|
236
|
+
# bash like
|
|
237
|
+
"Complete" {
|
|
238
|
+
|
|
239
|
+
if ($Values.Length -eq 1) {
|
|
240
|
+
__${name.value}_debug "Only one completion left"
|
|
241
|
+
|
|
242
|
+
# insert space after value
|
|
243
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
244
|
+
|
|
245
|
+
} else {
|
|
246
|
+
# Add the proper number of spaces to align the descriptions
|
|
247
|
+
while($comp.Name.Length -lt $Longest) {
|
|
248
|
+
$comp.Name = $comp.Name + " "
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# Check for empty description and only add parentheses if needed
|
|
252
|
+
if ($($comp.Description) -eq " " ) {
|
|
253
|
+
$Description = ""
|
|
254
|
+
} else {
|
|
255
|
+
$Description = " ($($comp.Description))"
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
# zsh like
|
|
263
|
+
"MenuComplete" {
|
|
264
|
+
# insert space after value
|
|
265
|
+
# MenuComplete will automatically show the ToolTip of
|
|
266
|
+
# the highlighted value at the bottom of the suggestions.
|
|
267
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
# TabCompleteNext and in case we get something unknown
|
|
271
|
+
Default {
|
|
272
|
+
# Like MenuComplete but we don't want to add a space here because
|
|
273
|
+
# the user need to press space anyway to get the completion.
|
|
274
|
+
# Description will not be shown because that's not possible with TabCompleteNext
|
|
275
|
+
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${name.value}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
Register-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${name.value}CompleterBlock
|
|
282
|
+
\`; `;
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
286
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
287
|
+
"export": true,
|
|
288
|
+
"const": true,
|
|
289
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
290
|
+
initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
291
|
+
if (!line.trim()) {
|
|
292
|
+
return "";
|
|
293
|
+
}
|
|
294
|
+
if (line.trim().startsWith("#")) {
|
|
295
|
+
return \`\${colors.dim(line)}\`;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
|
|
299
|
+
.replaceAll(/\\".*\\"/g, colors.cyan("$&"))
|
|
300
|
+
.replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|::new|::OutputEncoding|::UTF8)/g, colors.bold(colors.gray("$&")))
|
|
301
|
+
.replaceAll(/(switch|complete)\\s+/g, colors.green("$&"))
|
|
302
|
+
.replaceAll(/(?<=(switch|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
|
|
303
|
+
.replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\w+)\\s+/g, colors.red("$&"))
|
|
304
|
+
.replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\w+)\\s+)\\w/g, colors.bold(colors.redBright("$&")))
|
|
305
|
+
.replaceAll(/while\\s+/g, colors.cyan("$&"))
|
|
306
|
+
.replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
|
|
307
|
+
.replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
|
|
308
|
+
.replaceAll(/\\$?__\\w/g, colors.bold(colors.magentaBright("$&")))
|
|
309
|
+
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
|
|
310
|
+
|
|
311
|
+
}).join("\\n"); `
|
|
312
|
+
})
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
//#endregion
|
|
319
|
+
exports.PowerShellCompletionsShared = PowerShellCompletionsShared;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/components/powershell-shared.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The PowerShell Completions generation for the Shell Shock project.
|
|
6
|
+
*/
|
|
7
|
+
declare function PowerShellCompletionsShared(): _$_alloy_js_core0.Children;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { PowerShellCompletionsShared };
|
|
10
|
+
//# sourceMappingURL=powershell-shared.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powershell-shared.d.cts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":";;;;;;iBAiCgB,2BAAA,CAAA,GAA2B,iBAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/components/powershell-shared.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The PowerShell Completions generation for the Shell Shock project.
|
|
6
|
+
*/
|
|
7
|
+
declare function PowerShellCompletionsShared(): _$_alloy_js_core0.Children;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { PowerShellCompletionsShared };
|
|
10
|
+
//# sourceMappingURL=powershell-shared.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powershell-shared.d.mts","names":[],"sources":["../../src/components/powershell-shared.tsx"],"mappings":";;;;;;iBAiCgB,2BAAA,CAAA,GAA2B,iBAAA,CAAA,QAAA"}
|