@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.
- package/dist/components/bash-config-command.cjs +120 -6
- package/dist/components/bash-config-command.mjs +119 -6
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +105 -5
- package/dist/components/bash-script-command.mjs +104 -5
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +77 -13
- package/dist/components/bash-shared.mjs +76 -13
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +120 -6
- package/dist/components/fish-config-command.mjs +119 -6
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +104 -4
- package/dist/components/fish-script-command.mjs +103 -4
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +141 -77
- package/dist/components/fish-shared.mjs +140 -77
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/index.cjs +26 -1
- package/dist/components/index.mjs +14 -1
- package/dist/components/powershell-config-command.cjs +116 -6
- package/dist/components/powershell-config-command.mjs +115 -6
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +104 -4
- package/dist/components/powershell-script-command.mjs +103 -4
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +101 -37
- package/dist/components/powershell-shared.mjs +100 -37
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +120 -6
- package/dist/components/zsh-config-command.mjs +119 -6
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +108 -6
- package/dist/components/zsh-script-command.mjs +107 -6
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +106 -42
- package/dist/components/zsh-shared.mjs +105 -42
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +10 -1
- package/dist/helpers/complete-command.mjs +8 -1
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/completion-directive-constants.cjs +16 -1
- package/dist/helpers/completion-directive-constants.mjs +14 -1
- package/dist/helpers/completion-directive-constants.mjs.map +1 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +4 -1
- package/dist/index.cjs +303 -1
- package/dist/index.mjs +301 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +4 -1
- package/dist/types/index.mjs +3 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/shell-type.cjs +12 -1
- package/dist/types/shell-type.mjs +10 -1
- package/dist/types/shell-type.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,8 +1,98 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
+
let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
|
|
8
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
|
+
let _stryke_path = require("@stryke/path");
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
//#region src/components/fish-script-command.tsx
|
|
14
|
+
/**
|
|
15
|
+
* The Fish Completions - Script command's handler wrapper for the Shell Shock project.
|
|
16
|
+
*/
|
|
17
|
+
function FishScriptCompletionsCommand() {
|
|
18
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
19
|
+
const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
|
|
20
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
21
|
+
get path() {
|
|
22
|
+
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "script", "command.ts");
|
|
23
|
+
},
|
|
24
|
+
imports: {
|
|
25
|
+
"node:os": "os",
|
|
26
|
+
"node:path": ["join"],
|
|
27
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
28
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
29
|
+
},
|
|
30
|
+
builtinImports: { console: [
|
|
31
|
+
"bold",
|
|
32
|
+
"writeLine",
|
|
33
|
+
"success",
|
|
34
|
+
"warn",
|
|
35
|
+
"help"
|
|
36
|
+
] },
|
|
37
|
+
get children() {
|
|
38
|
+
return [
|
|
39
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Fish Completions - Script command." }),
|
|
40
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
41
|
+
"export": true,
|
|
42
|
+
name: "FishScriptCompletionsOptions",
|
|
43
|
+
get children() {
|
|
44
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
45
|
+
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.",
|
|
46
|
+
get children() {
|
|
47
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
48
|
+
get type() {
|
|
49
|
+
return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
|
|
50
|
+
},
|
|
51
|
+
defaultValue: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
55
|
+
name: "display",
|
|
56
|
+
optional: true,
|
|
57
|
+
type: "boolean"
|
|
58
|
+
})];
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
62
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions fish script\\` command." }),
|
|
63
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
64
|
+
"export": true,
|
|
65
|
+
"default": true,
|
|
66
|
+
async: true,
|
|
67
|
+
name: "handler",
|
|
68
|
+
get parameters() {
|
|
69
|
+
return [{
|
|
70
|
+
name: "options",
|
|
71
|
+
type: "FishScriptCompletionsOptions",
|
|
72
|
+
default: "{}"
|
|
73
|
+
}, {
|
|
74
|
+
name: "path",
|
|
75
|
+
type: "string",
|
|
76
|
+
default: `"./${bin.value}-completions.fish"`
|
|
77
|
+
}];
|
|
78
|
+
},
|
|
79
|
+
get children() {
|
|
80
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
81
|
+
condition: _alloy_js_core.code`options.display !== true`,
|
|
82
|
+
get children() {
|
|
83
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
84
|
+
"const": true,
|
|
85
|
+
name: "scriptPath",
|
|
86
|
+
type: "string",
|
|
87
|
+
initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.fish\` : path;`
|
|
88
|
+
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# Fish script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
89
|
+
|
|
90
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
91
|
+
}
|
|
92
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
93
|
+
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
4
94
|
writeLine("");
|
|
5
|
-
writeLine(\`# Fish completion for ${(0,
|
|
95
|
+
writeLine(\`# Fish completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\`);
|
|
6
96
|
writeLine("");
|
|
7
97
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
8
98
|
writeLine("");
|
|
@@ -12,4 +102,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
12
102
|
help(\`To enable these completions, perform one of the following actions:
|
|
13
103
|
|
|
14
104
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/fish/config.fish)
|
|
15
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
105
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
106
|
+
} })];
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
exports.FishScriptCompletionsCommand = FishScriptCompletionsCommand;
|
|
@@ -1,8 +1,97 @@
|
|
|
1
|
-
import
|
|
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";
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
//#region src/components/fish-script-command.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The Fish Completions - Script command's handler wrapper for the Shell Shock project.
|
|
15
|
+
*/
|
|
16
|
+
function FishScriptCompletionsCommand() {
|
|
17
|
+
const context = usePowerlines();
|
|
18
|
+
const bin = computed(() => getAppBin(context));
|
|
19
|
+
return createComponent(TypescriptFile, {
|
|
20
|
+
get path() {
|
|
21
|
+
return joinPaths(context.entryPath, "completions", "fish", "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: { console: [
|
|
30
|
+
"bold",
|
|
31
|
+
"writeLine",
|
|
32
|
+
"success",
|
|
33
|
+
"warn",
|
|
34
|
+
"help"
|
|
35
|
+
] },
|
|
36
|
+
get children() {
|
|
37
|
+
return [
|
|
38
|
+
createComponent(TSDoc$1, { heading: "Options for the Fish Completions - Script command." }),
|
|
39
|
+
createComponent(InterfaceDeclaration, {
|
|
40
|
+
"export": true,
|
|
41
|
+
name: "FishScriptCompletionsOptions",
|
|
42
|
+
get children() {
|
|
43
|
+
return [createComponent(TSDoc$1, {
|
|
44
|
+
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.",
|
|
45
|
+
get children() {
|
|
46
|
+
return createComponent(TSDocDefaultValue$1, {
|
|
47
|
+
get type() {
|
|
48
|
+
return ReflectionKind.boolean;
|
|
49
|
+
},
|
|
50
|
+
defaultValue: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}), createComponent(InterfaceMember$1, {
|
|
54
|
+
name: "display",
|
|
55
|
+
optional: true,
|
|
56
|
+
type: "boolean"
|
|
57
|
+
})];
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
createComponent(Spacing, {}),
|
|
61
|
+
createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions fish script\\` command." }),
|
|
62
|
+
createComponent(FunctionDeclaration, {
|
|
63
|
+
"export": true,
|
|
64
|
+
"default": true,
|
|
65
|
+
async: true,
|
|
66
|
+
name: "handler",
|
|
67
|
+
get parameters() {
|
|
68
|
+
return [{
|
|
69
|
+
name: "options",
|
|
70
|
+
type: "FishScriptCompletionsOptions",
|
|
71
|
+
default: "{}"
|
|
72
|
+
}, {
|
|
73
|
+
name: "path",
|
|
74
|
+
type: "string",
|
|
75
|
+
default: `"./${bin.value}-completions.fish"`
|
|
76
|
+
}];
|
|
77
|
+
},
|
|
78
|
+
get children() {
|
|
79
|
+
return [createComponent(IfStatement, {
|
|
80
|
+
condition: code`options.display !== true`,
|
|
81
|
+
get children() {
|
|
82
|
+
return [createComponent(VarDeclaration, {
|
|
83
|
+
"const": true,
|
|
84
|
+
name: "scriptPath",
|
|
85
|
+
type: "string",
|
|
86
|
+
initializer: code` path.includes(".") ? \`\${path}.fish\` : path;`
|
|
87
|
+
}), memo(() => code`await writeFile(scriptPath, \`# Fish script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
88
|
+
|
|
89
|
+
success(\`${getAppTitle(context)} Fish completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
90
|
+
}
|
|
91
|
+
}), createComponent(ElseClause, { get children() {
|
|
92
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
4
93
|
writeLine("");
|
|
5
|
-
writeLine(\`# Fish completion for ${
|
|
94
|
+
writeLine(\`# Fish completion for ${getAppTitle(context)}\`);
|
|
6
95
|
writeLine("");
|
|
7
96
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
8
97
|
writeLine("");
|
|
@@ -12,5 +101,15 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
|
|
|
12
101
|
help(\`To enable these completions, perform one of the following actions:
|
|
13
102
|
|
|
14
103
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/fish/config.fish)
|
|
15
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
104
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
105
|
+
} })];
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { FishScriptCompletionsCommand };
|
|
16
115
|
//# sourceMappingURL=fish-script-command.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fish-script-command.mjs","names":[],"sources":["../../src/components/fish-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 Fish Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function FishScriptCompletionsCommand() {\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 \"fish\",\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 Fish Completions - Script command.\" />\n <InterfaceDeclaration export name=\"FishScriptCompletionsOptions\">\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 fish script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"./${bin.value}-completions.fish\"`\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}.fish\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Fish script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Fish completion script has been generated at \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`# Fish 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/fish/config.fish)\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":"
|
|
1
|
+
{"version":3,"file":"fish-script-command.mjs","names":[],"sources":["../../src/components/fish-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 Fish Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function FishScriptCompletionsCommand() {\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 \"fish\",\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 Fish Completions - Script command.\" />\n <InterfaceDeclaration export name=\"FishScriptCompletionsOptions\">\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 fish script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"./${bin.value}-completions.fish\"`\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}.fish\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Fish script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Fish completion script has been generated at \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`# Fish 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/fish/config.fish)\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":";;;;;;;;;;;;;;;AA+BA,SAAE,+BAAA;CACA,MAAM,UAAC,eAAwB;CACjC,MAAO,MAAA,eAAA,UAAA,QAAA,CAAA;AACL,QAAK,gBAAA,gBAAA;EACL,IAAA,OAAA;AACI,UAAG,UAAW,QAAO,WAAM,eAAsB,QAAM,UAAA,aAAA;;EAE7D,SAAS;GACH,WAAQ;;GAEZ,oBAAA,CAAA,YAAA,YAAA;GACI,aAAM,CAAA,qBAA6B,4BAA0B;GACjE;EACF,gBAAgB,EACd,SAAa;GAAC;GAAE;GAAc;GAAA;GAAwB;GAAG;EAEzD,IAAM,WAAM;;+BAEN,SAAC,sDACJ,CAAA;IAAA,gBAAA,sBAAA;KACC,UAAM;KACJ,MAAA;KACA,IAAC,WAAY;AACZ,aAAK,CAAA,gBAAA,SAAA;OACL,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,gEACV,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,MAAA,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,sEAAA,YAAA,QAAA,CAAA;;wBAEO,YAAU,QAAA,CAAA,yEAAA,CAAA;;OAEjB,CAAC,EAAA,gBAAmB,YAAa,EACjC,IAAA,WAAA;AACA,cAAU,IAAC;;gDAEa,YAAA,QAAA,CAAA;;;;;;;;;;;;;KAc5B,CAAC;IAAC;;EAEN,CAAC"}
|