@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,27 +1,75 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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/bash-shared.tsx
|
|
16
|
+
/**
|
|
17
|
+
* The Bash Completions generation for the Shell Shock project.
|
|
18
|
+
*/
|
|
19
|
+
function BashCompletionsShared() {
|
|
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", "bash", "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
|
+
"export": true,
|
|
46
|
+
"const": true,
|
|
47
|
+
name: "SHELL_COMPLETIONS",
|
|
48
|
+
get initializer() {
|
|
49
|
+
return _alloy_js_core.code` \`# Define shell completion directives
|
|
50
|
+
readonly ShellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
|
|
51
|
+
readonly ShellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
|
|
52
|
+
readonly ShellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
|
|
53
|
+
readonly ShellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
54
|
+
readonly ShellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
|
|
55
|
+
readonly ShellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
|
|
8
56
|
|
|
9
57
|
# Function to debug completion
|
|
10
|
-
__${
|
|
58
|
+
__${name.value}_debug() {
|
|
11
59
|
if [[ -n \\\${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
12
60
|
echo "$*" >> "\\\${BASH_COMP_DEBUG_FILE}"
|
|
13
61
|
fi
|
|
14
62
|
}
|
|
15
63
|
|
|
16
64
|
# Function to handle completions
|
|
17
|
-
__${
|
|
65
|
+
__${name.value}_complete() {
|
|
18
66
|
local cur prev words cword
|
|
19
67
|
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
20
68
|
|
|
21
69
|
local requestComp out directive
|
|
22
70
|
|
|
23
71
|
# Build the command to get completions
|
|
24
|
-
requestComp="${
|
|
72
|
+
requestComp="${require_helpers_complete_command.EXEC_COMMAND} complete -- \\\${words[@]:1}"
|
|
25
73
|
|
|
26
74
|
# Add an empty parameter if the last parameter is complete
|
|
27
75
|
if [[ -z "$cur" ]]; then
|
|
@@ -96,8 +144,16 @@ __${p.value}_complete() {
|
|
|
96
144
|
}
|
|
97
145
|
|
|
98
146
|
# Register completion function
|
|
99
|
-
complete -F __${
|
|
100
|
-
\`;
|
|
147
|
+
complete -F __${name.value}_complete ${bin.value}
|
|
148
|
+
\`; `;
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
152
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
153
|
+
"export": true,
|
|
154
|
+
"const": true,
|
|
155
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
156
|
+
initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
101
157
|
if (!line.trim()) {
|
|
102
158
|
return "";
|
|
103
159
|
}
|
|
@@ -118,4 +174,12 @@ complete -F __${p.value}_complete ${f.value}
|
|
|
118
174
|
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
119
175
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
120
176
|
|
|
121
|
-
}).join("\\n"); `
|
|
177
|
+
}).join("\\n"); `
|
|
178
|
+
})
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
exports.BashCompletionsShared = BashCompletionsShared;
|
|
@@ -1,27 +1,74 @@
|
|
|
1
|
-
import{EXEC_COMMAND
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
|
|
2
|
+
import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
|
|
3
|
+
import "../helpers/index.mjs";
|
|
4
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { getAppBin } from "@shell-shock/core/plugin-utils";
|
|
6
|
+
import { code, computed } from "@alloy-js/core";
|
|
7
|
+
import { VarDeclaration } from "@alloy-js/typescript";
|
|
8
|
+
import { Spacing } from "@powerlines/plugin-alloy/core";
|
|
9
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
10
|
+
import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
|
|
11
|
+
import { joinPaths } from "@stryke/path";
|
|
12
|
+
import { snakeCase } from "@stryke/string-format/snake-case";
|
|
13
|
+
|
|
14
|
+
//#region src/components/bash-shared.tsx
|
|
15
|
+
/**
|
|
16
|
+
* The Bash Completions generation for the Shell Shock project.
|
|
17
|
+
*/
|
|
18
|
+
function BashCompletionsShared() {
|
|
19
|
+
const context = usePowerlines();
|
|
20
|
+
const bin = computed(() => getAppBin(context));
|
|
21
|
+
const name = computed(() => snakeCase(bin.value));
|
|
22
|
+
return createComponent(TypescriptFile, {
|
|
23
|
+
get path() {
|
|
24
|
+
return joinPaths(context.entryPath, "completions", "bash", "shared.ts");
|
|
25
|
+
},
|
|
26
|
+
builtinImports: { console: [
|
|
27
|
+
"white",
|
|
28
|
+
"green",
|
|
29
|
+
"red",
|
|
30
|
+
"bold",
|
|
31
|
+
"cyan",
|
|
32
|
+
"gray",
|
|
33
|
+
"magenta",
|
|
34
|
+
"magentaBright",
|
|
35
|
+
"greenBright",
|
|
36
|
+
"redBright",
|
|
37
|
+
"cyanBright",
|
|
38
|
+
"dim"
|
|
39
|
+
] },
|
|
40
|
+
get children() {
|
|
41
|
+
return [
|
|
42
|
+
createComponent(Spacing, {}),
|
|
43
|
+
createComponent(VarDeclaration, {
|
|
44
|
+
"export": true,
|
|
45
|
+
"const": true,
|
|
46
|
+
name: "SHELL_COMPLETIONS",
|
|
47
|
+
get initializer() {
|
|
48
|
+
return code` \`# Define shell completion directives
|
|
49
|
+
readonly ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}
|
|
50
|
+
readonly ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}
|
|
51
|
+
readonly ShellCompDirectiveNoFileComp=${CompletionDirective.CompletionDirectiveNoFileComp}
|
|
52
|
+
readonly ShellCompDirectiveFilterFileExt=${CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
53
|
+
readonly ShellCompDirectiveFilterDirs=${CompletionDirective.CompletionDirectiveFilterDirs}
|
|
54
|
+
readonly ShellCompDirectiveKeepOrder=${CompletionDirective.CompletionDirectiveKeepOrder}
|
|
8
55
|
|
|
9
56
|
# Function to debug completion
|
|
10
|
-
__${
|
|
57
|
+
__${name.value}_debug() {
|
|
11
58
|
if [[ -n \\\${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
12
59
|
echo "$*" >> "\\\${BASH_COMP_DEBUG_FILE}"
|
|
13
60
|
fi
|
|
14
61
|
}
|
|
15
62
|
|
|
16
63
|
# Function to handle completions
|
|
17
|
-
__${
|
|
64
|
+
__${name.value}_complete() {
|
|
18
65
|
local cur prev words cword
|
|
19
66
|
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
20
67
|
|
|
21
68
|
local requestComp out directive
|
|
22
69
|
|
|
23
70
|
# Build the command to get completions
|
|
24
|
-
requestComp="${
|
|
71
|
+
requestComp="${EXEC_COMMAND} complete -- \\\${words[@]:1}"
|
|
25
72
|
|
|
26
73
|
# Add an empty parameter if the last parameter is complete
|
|
27
74
|
if [[ -z "$cur" ]]; then
|
|
@@ -96,8 +143,16 @@ __${m.value}_complete() {
|
|
|
96
143
|
}
|
|
97
144
|
|
|
98
145
|
# Register completion function
|
|
99
|
-
complete -F __${
|
|
100
|
-
\`;
|
|
146
|
+
complete -F __${name.value}_complete ${bin.value}
|
|
147
|
+
\`; `;
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
createComponent(Spacing, {}),
|
|
151
|
+
createComponent(VarDeclaration, {
|
|
152
|
+
"export": true,
|
|
153
|
+
"const": true,
|
|
154
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
155
|
+
initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
101
156
|
if (!line.trim()) {
|
|
102
157
|
return "";
|
|
103
158
|
}
|
|
@@ -118,5 +173,13 @@ complete -F __${m.value}_complete ${p.value}
|
|
|
118
173
|
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
119
174
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
120
175
|
|
|
121
|
-
}).join("\\n"); `
|
|
176
|
+
}).join("\\n"); `
|
|
177
|
+
})
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
export { BashCompletionsShared };
|
|
122
185
|
//# sourceMappingURL=bash-shared.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-shared.mjs","names":[],"sources":["../../src/components/bash-shared.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 { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Bash Completions generation for the Shell Shock project.\n */\nexport function BashCompletionsShared() {\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(context.entryPath, \"completions\", \"bash\", \"shared.ts\")}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`# Define shell completion directives\nreadonly ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\nreadonly ShellCompDirectiveNoSpace=${\n CompletionDirective.CompletionDirectiveNoSpace\n }\nreadonly ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\nreadonly ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\nreadonly ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\nreadonly ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n# Function to debug completion\n__${name.value}_debug() {\n if [[ -n \\\\\\${BASH_COMP_DEBUG_FILE:-} ]]; then\n echo \"$*\" >> \"\\\\\\${BASH_COMP_DEBUG_FILE}\"\n fi\n}\n\n# Function to handle completions\n__${name.value}_complete() {\n local cur prev words cword\n _get_comp_words_by_ref -n \"=:\" cur prev words cword\n\n local requestComp out directive\n\n # Build the command to get completions\n requestComp=\"${EXEC_COMMAND} complete -- \\\\\\${words[@]:1}\"\n\n # Add an empty parameter if the last parameter is complete\n if [[ -z \"$cur\" ]]; then\n requestComp=\"$requestComp ''\"\n fi\n\n # Get completions from the program\n out=$(eval \"$requestComp\" 2>/dev/null)\n\n # Extract directive if present\n directive=0\n if [[ \"$out\" == *:* ]]; then\n directive=\\\\\\${out##*:}\n out=\\\\\\${out%:*}\n fi\n\n # Process completions based on directive\n if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then\n # Error, no completion\n return\n fi\n\n # Apply directives\n if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then\n compopt -o nospace\n fi\n if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then\n compopt -o nosort\n fi\n if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then\n compopt +o default\n fi\n\n # Handle file extension filtering\n if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then\n local filter=\"\"\n for ext in $out; do\n filter=\"$filter|$ext\"\n done\n filter=\"\\\\.($filter)\"\n compopt -o filenames\n COMPREPLY=( $(compgen -f -X \"!$filter\" -- \"$cur\") )\n return\n fi\n\n # Handle directory filtering\n if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then\n compopt -o dirnames\n COMPREPLY=( $(compgen -d -- \"$cur\") )\n return\n fi\n\n # Process completions\n local IFS=$'\\\\n'\n local tab=$(printf '\\\\t')\n\n # Parse completions with descriptions\n local completions=()\n while read -r comp; do\n if [[ \"$comp\" == *$tab* ]]; then\n # Split completion and description\n local value=\\\\\\${comp%%$tab*}\n local desc=\\\\\\${comp#*$tab}\n completions+=(\"$value\")\n else\n completions+=(\"$comp\")\n fi\n done <<< \"$out\"\n\n # Return completions\n COMPREPLY=( $(compgen -W \"\\\\\\${completions[*]}\" -- \"$cur\") )\n}\n\n# Register completion function\ncomplete -F __${name.value}_complete ${bin.value}\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, bold(gray(\"$&\")))\n .replaceAll(/(readonly|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(readonly|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/local\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=local\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bash-shared.mjs","names":[],"sources":["../../src/components/bash-shared.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 { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Bash Completions generation for the Shell Shock project.\n */\nexport function BashCompletionsShared() {\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(context.entryPath, \"completions\", \"bash\", \"shared.ts\")}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`# Define shell completion directives\nreadonly ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\nreadonly ShellCompDirectiveNoSpace=${\n CompletionDirective.CompletionDirectiveNoSpace\n }\nreadonly ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\nreadonly ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\nreadonly ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\nreadonly ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n# Function to debug completion\n__${name.value}_debug() {\n if [[ -n \\\\\\${BASH_COMP_DEBUG_FILE:-} ]]; then\n echo \"$*\" >> \"\\\\\\${BASH_COMP_DEBUG_FILE}\"\n fi\n}\n\n# Function to handle completions\n__${name.value}_complete() {\n local cur prev words cword\n _get_comp_words_by_ref -n \"=:\" cur prev words cword\n\n local requestComp out directive\n\n # Build the command to get completions\n requestComp=\"${EXEC_COMMAND} complete -- \\\\\\${words[@]:1}\"\n\n # Add an empty parameter if the last parameter is complete\n if [[ -z \"$cur\" ]]; then\n requestComp=\"$requestComp ''\"\n fi\n\n # Get completions from the program\n out=$(eval \"$requestComp\" 2>/dev/null)\n\n # Extract directive if present\n directive=0\n if [[ \"$out\" == *:* ]]; then\n directive=\\\\\\${out##*:}\n out=\\\\\\${out%:*}\n fi\n\n # Process completions based on directive\n if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then\n # Error, no completion\n return\n fi\n\n # Apply directives\n if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then\n compopt -o nospace\n fi\n if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then\n compopt -o nosort\n fi\n if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then\n compopt +o default\n fi\n\n # Handle file extension filtering\n if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then\n local filter=\"\"\n for ext in $out; do\n filter=\"$filter|$ext\"\n done\n filter=\"\\\\.($filter)\"\n compopt -o filenames\n COMPREPLY=( $(compgen -f -X \"!$filter\" -- \"$cur\") )\n return\n fi\n\n # Handle directory filtering\n if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then\n compopt -o dirnames\n COMPREPLY=( $(compgen -d -- \"$cur\") )\n return\n fi\n\n # Process completions\n local IFS=$'\\\\n'\n local tab=$(printf '\\\\t')\n\n # Parse completions with descriptions\n local completions=()\n while read -r comp; do\n if [[ \"$comp\" == *$tab* ]]; then\n # Split completion and description\n local value=\\\\\\${comp%%$tab*}\n local desc=\\\\\\${comp#*$tab}\n completions+=(\"$value\")\n else\n completions+=(\"$comp\")\n fi\n done <<< \"$out\"\n\n # Return completions\n COMPREPLY=( $(compgen -W \"\\\\\\${completions[*]}\" -- \"$cur\") )\n}\n\n# Register completion function\ncomplete -F __${name.value}_complete ${bin.value}\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, bold(gray(\"$&\")))\n .replaceAll(/(readonly|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(readonly|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/local\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=local\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAE,wBAAA;CACF,MAAO,UAAS,eAAA;CACd,MAAM,MAAA,eAAU,UAAc,QAAA,CAAA;;AAE9B,QAAM,gBAAmB,gBAAY;EACrC,IAAM,OAAO;;;EAGX,gBAAC,EACC,SAAM;GAAA;GAAU;GAAQ;GAAW;GAAC;GAAe;GAAQ;GAAW;GAAA;GAAA;GAAA;GAAA;GAAA,EACvE;EACD,IAAI,WAAS;AACX,UAAK;IAAA,gBAAM,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACT,UAAS;KACT,SAAO;KACP,MAAG;KACH,IAAG,cAAK;AACN,aAAM,IAAA;mCACG,oBAAA,yBAAA;qCACM,oBAAA,2BAAA;wCACF,oBAAA,8BAAA;2CACF,oBAAA,iCAAA;wCACC,oBAAA,8BAAA;uCACR,oBAAA,6BAAA;;;IAGV,KAAG,MAAQ;;;;;;;IAOf,KAAS,MAAA;;;;;;;mBAOC,aAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2E1B,KAAA,MAAA,YAAA,IAAA,MAAA;;;KAGA,CAAA;IAAM,gBAAS,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACf,UAAY;;KAEV,MAAM;KACR,aAAiB,IAAE;;;;;;;;;;;;;;;;;;;;;;KAsBhB,CAAC;IAAA;;EAEL,CAAC"}
|
|
@@ -1,4 +1,104 @@
|
|
|
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 _stryke_path = require("@stryke/path");
|
|
11
|
+
let _powerlines_plugin_alloy_typescript_components_typescript_file = require("@powerlines/plugin-alloy/typescript/components/typescript-file");
|
|
12
|
+
|
|
13
|
+
//#region src/components/fish-config-command.tsx
|
|
14
|
+
/**
|
|
15
|
+
* The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.
|
|
16
|
+
*/
|
|
17
|
+
function FishConfigCompletionsCommand() {
|
|
18
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
19
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_typescript_file.TypescriptFile, {
|
|
20
|
+
get path() {
|
|
21
|
+
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "config", "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
|
+
"inlineCode",
|
|
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.TSDoc, { heading: "Options for the Fish Completions - Configuration command." }),
|
|
40
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
41
|
+
"export": true,
|
|
42
|
+
name: "FishConfigCompletionsOptions",
|
|
43
|
+
get children() {
|
|
44
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.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.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)(_alloy_js_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.TSDoc, { heading: "Handler logic for the \\`completions fish config\\` 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
|
+
parameters: [{
|
|
69
|
+
name: "options",
|
|
70
|
+
type: "FishConfigCompletionsOptions",
|
|
71
|
+
default: "{}"
|
|
72
|
+
}, {
|
|
73
|
+
name: "path",
|
|
74
|
+
type: "string",
|
|
75
|
+
default: `"~/.config/fish/config.fish"`
|
|
76
|
+
}],
|
|
77
|
+
get children() {
|
|
78
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
79
|
+
condition: _alloy_js_core.code`options.display !== true`,
|
|
80
|
+
get children() {
|
|
81
|
+
return [
|
|
82
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
83
|
+
"let": true,
|
|
84
|
+
name: "configPath",
|
|
85
|
+
type: "string",
|
|
86
|
+
initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, ".config", "fish", "config.fish");`
|
|
87
|
+
}),
|
|
88
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
89
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
90
|
+
condition: _alloy_js_core.code`configPath.startsWith("~")`,
|
|
91
|
+
children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
92
|
+
}),
|
|
93
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
94
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
95
|
+
"let": true,
|
|
96
|
+
name: "content",
|
|
97
|
+
type: "string",
|
|
98
|
+
initializer: _alloy_js_core.code`"";`
|
|
99
|
+
}),
|
|
100
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
101
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
|
|
2
102
|
content = await readFile(configPath, "utf8");
|
|
3
103
|
} catch (error) {
|
|
4
104
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
@@ -9,15 +109,19 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
9
109
|
}
|
|
10
110
|
}
|
|
11
111
|
|
|
12
|
-
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0,
|
|
112
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\`);
|
|
13
113
|
|
|
14
|
-
success(\`${(0,
|
|
114
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Fish configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
118
|
+
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
15
119
|
writeLine("");
|
|
16
|
-
writeLine(\`### Begin - ${(0,
|
|
120
|
+
writeLine(\`### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\`);
|
|
17
121
|
writeLine("");
|
|
18
122
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
19
123
|
writeLine("");
|
|
20
|
-
writeLine(\`### End - ${(0,
|
|
124
|
+
writeLine(\`### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\`);
|
|
21
125
|
writeLine("");
|
|
22
126
|
writeLine(" ------------------------------------------------- ");
|
|
23
127
|
|
|
@@ -25,4 +129,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
25
129
|
help(\`To enable these completions, perform one of the following actions:
|
|
26
130
|
|
|
27
131
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/fish/config.fish)
|
|
28
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
132
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
133
|
+
} })];
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
exports.FishConfigCompletionsCommand = FishConfigCompletionsCommand;
|
|
@@ -1,4 +1,103 @@
|
|
|
1
|
-
import{createComponent
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { code } from "@alloy-js/core";
|
|
4
|
+
import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, 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 { TSDoc, TSDocDefaultValue } from "@powerlines/plugin-alloy/typescript";
|
|
9
|
+
import { joinPaths } from "@stryke/path";
|
|
10
|
+
import { TypescriptFile as TypescriptFile$1 } from "@powerlines/plugin-alloy/typescript/components/typescript-file";
|
|
11
|
+
|
|
12
|
+
//#region src/components/fish-config-command.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.
|
|
15
|
+
*/
|
|
16
|
+
function FishConfigCompletionsCommand() {
|
|
17
|
+
const context = usePowerlines();
|
|
18
|
+
return createComponent(TypescriptFile$1, {
|
|
19
|
+
get path() {
|
|
20
|
+
return joinPaths(context.entryPath, "completions", "fish", "config", "command.ts");
|
|
21
|
+
},
|
|
22
|
+
imports: {
|
|
23
|
+
"node:os": "os",
|
|
24
|
+
"node:path": ["join"],
|
|
25
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
26
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
27
|
+
},
|
|
28
|
+
builtinImports: { console: [
|
|
29
|
+
"bold",
|
|
30
|
+
"inlineCode",
|
|
31
|
+
"writeLine",
|
|
32
|
+
"success",
|
|
33
|
+
"warn",
|
|
34
|
+
"help"
|
|
35
|
+
] },
|
|
36
|
+
get children() {
|
|
37
|
+
return [
|
|
38
|
+
createComponent(TSDoc, { heading: "Options for the Fish Completions - Configuration command." }),
|
|
39
|
+
createComponent(InterfaceDeclaration, {
|
|
40
|
+
"export": true,
|
|
41
|
+
name: "FishConfigCompletionsOptions",
|
|
42
|
+
get children() {
|
|
43
|
+
return [createComponent(TSDoc, {
|
|
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, {
|
|
47
|
+
get type() {
|
|
48
|
+
return ReflectionKind.boolean;
|
|
49
|
+
},
|
|
50
|
+
defaultValue: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}), createComponent(InterfaceMember, {
|
|
54
|
+
name: "display",
|
|
55
|
+
optional: true,
|
|
56
|
+
type: "boolean"
|
|
57
|
+
})];
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
createComponent(Spacing, {}),
|
|
61
|
+
createComponent(TSDoc, { heading: "Handler logic for the \\`completions fish config\\` command." }),
|
|
62
|
+
createComponent(FunctionDeclaration, {
|
|
63
|
+
"export": true,
|
|
64
|
+
"default": true,
|
|
65
|
+
async: true,
|
|
66
|
+
name: "handler",
|
|
67
|
+
parameters: [{
|
|
68
|
+
name: "options",
|
|
69
|
+
type: "FishConfigCompletionsOptions",
|
|
70
|
+
default: "{}"
|
|
71
|
+
}, {
|
|
72
|
+
name: "path",
|
|
73
|
+
type: "string",
|
|
74
|
+
default: `"~/.config/fish/config.fish"`
|
|
75
|
+
}],
|
|
76
|
+
get children() {
|
|
77
|
+
return [createComponent(IfStatement, {
|
|
78
|
+
condition: code`options.display !== true`,
|
|
79
|
+
get children() {
|
|
80
|
+
return [
|
|
81
|
+
createComponent(VarDeclaration, {
|
|
82
|
+
"let": true,
|
|
83
|
+
name: "configPath",
|
|
84
|
+
type: "string",
|
|
85
|
+
initializer: code` path.includes(".") ? path : join(path, ".config", "fish", "config.fish");`
|
|
86
|
+
}),
|
|
87
|
+
createComponent(Spacing, {}),
|
|
88
|
+
createComponent(IfStatement, {
|
|
89
|
+
condition: code`configPath.startsWith("~")`,
|
|
90
|
+
children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
91
|
+
}),
|
|
92
|
+
createComponent(Spacing, {}),
|
|
93
|
+
createComponent(VarDeclaration, {
|
|
94
|
+
"let": true,
|
|
95
|
+
name: "content",
|
|
96
|
+
type: "string",
|
|
97
|
+
initializer: code`"";`
|
|
98
|
+
}),
|
|
99
|
+
createComponent(Spacing, {}),
|
|
100
|
+
memo(() => code`try {
|
|
2
101
|
content = await readFile(configPath, "utf8");
|
|
3
102
|
} catch (error) {
|
|
4
103
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
@@ -9,15 +108,19 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
|
|
|
9
108
|
}
|
|
10
109
|
}
|
|
11
110
|
|
|
12
|
-
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${
|
|
111
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} Fish Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Fish Completions ###\`);
|
|
13
112
|
|
|
14
|
-
success(\`${
|
|
113
|
+
success(\`${getAppTitle(context)} shell completions have been applied to Fish configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
}), createComponent(ElseClause, { get children() {
|
|
117
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
15
118
|
writeLine("");
|
|
16
|
-
writeLine(\`### Begin - ${
|
|
119
|
+
writeLine(\`### Begin - ${getAppTitle(context)} Fish Completions ###\`);
|
|
17
120
|
writeLine("");
|
|
18
121
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
19
122
|
writeLine("");
|
|
20
|
-
writeLine(\`### End - ${
|
|
123
|
+
writeLine(\`### End - ${getAppTitle(context)} Fish Completions ###\`);
|
|
21
124
|
writeLine("");
|
|
22
125
|
writeLine(" ------------------------------------------------- ");
|
|
23
126
|
|
|
@@ -25,5 +128,15 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
|
|
|
25
128
|
help(\`To enable these completions, perform one of the following actions:
|
|
26
129
|
|
|
27
130
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/fish/config.fish)
|
|
28
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
131
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
132
|
+
} })];
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { FishConfigCompletionsCommand };
|
|
29
142
|
//# sourceMappingURL=fish-config-command.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fish-config-command.mjs","names":[],"sources":["../../src/components/fish-config-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 } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\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 { TSDoc, TSDocDefaultValue } from \"@powerlines/plugin-alloy/typescript\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function FishConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"fish\",\n \"config\",\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\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Fish Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"FishConfigCompletionsOptions\">\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 config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.config/fish/config.fish\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n let\n name=\"configPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? path : join(path, \".config\", \"fish\", \"config.fish\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Fish Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Fish Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Fish configuration file at \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`### Begin - ${getAppTitle(context)} Fish Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Fish Completions ###\\`);\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-config-command.mjs","names":[],"sources":["../../src/components/fish-config-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 } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\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 { TSDoc, TSDocDefaultValue } from \"@powerlines/plugin-alloy/typescript\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function FishConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"fish\",\n \"config\",\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\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Fish Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"FishConfigCompletionsOptions\">\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 config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.config/fish/config.fish\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n let\n name=\"configPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? path : join(path, \".config\", \"fish\", \"config.fish\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Fish Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Fish Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Fish configuration file at \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`### Begin - ${getAppTitle(context)} Fish Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Fish Completions ###\\`);\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,SAAS,+BAAmC;CAC5C,MAAQ,UAAC,eAAqB;AAC9B,QAAS,gBAAkB,kBAAa;EACxC,IAAO,OAAO;;;EAGX,SAAS;GACV,WAAA;GACI,aAAU,CAAA,OAAA;GACd,oBAAgB,CAAA,YAAc,YAAA;;GAE9B;EACE,gBAAC,EACC,SAAM;GAAA;GAAS;GAAA;GAAA;GAAA;GAAA;GAAA,EAChB;EACD,IAAI,WAAC;AACH,UAAO;IAAC,gBAAA,OAAA,EACN,SAAQ,6DACT,CAAC;IAAC,gBAAU,sBAAA;KACZ,UAAA;KACD,MAAQ;KACN,IAAC,WAAc;AACd,aAAK,CAAI,gBAAW,OAAA;OACpB,SAAQ;OACL,IAAA,WAAW;AAChB,eAAA,gBAAA,mBAAA;SACD,IAAc,OAAE;AACJ,iBAAO,eAAe;;SAE3B,cAAiB;SACvB,CAAA;;OAEI,CAAA,EAAA,gBAAA,iBAAA;OACC,MAAM;OACN,UAAA;OACD,MAAA;OACD,CAAA,CAAA;;KAEH,CAAC;IAAA,gBAAoB,SAAA,EAAA,CAAA;IAAA,gBAAA,OAAA,EACrB,SAAS,gEACT,CAAA;IAAA,gBAAe,qBAAwB;KACvC,UAAA;KACC,WAAA;KACA,OAAA;KACA,MAAA;KACA,YAAM,CAAO;MACb,MAAA;MACE,MAAA;MACA,SAAS;MACV,EAAE;MACD,MAAE;MACF,MAAC;MACD,SAAA;MACD,CAAC;KACF,IAAI,WAAO;AACT,aAAE,CAAA,gBAAqB,aAAgB;OACvC,WAAA,IAAA;OACA,IAAA,WAAA;AACD,eAAY;SAAA,gBAAgB,gBAAmB;UAC7C,OAAA;UACC,MAAA;UACI,MAAE;UACF,aAAQ,IAAA;UACZ,CAAA;SAAA,gBAAwB,SAAS,EAAE,CAAC;SAAE,gBAAkB,aAAa;UACtE,WAAA,IAAA;UACA,UAAS,IAAA;UACT,CAAA;SAAA,gBAAuB,SAAK,EAAA,CAAA;SAAW,gBAAiB,gBAAA;UACtD,OAAK;UACN,MAAA;UACD,MAAS;UACT,aAAA,IAAA;UACC,CAAA;SAAA,gBAAA,SAAA,EAAA,CAAA;SAAA,WAAA,IAAA;;;;;;;;;;;uEAW0D,YAAU,QAAQ,CAAA,mEAAiD,YAAA,QAAA,CAAA;;sBAEnH,YAAQ,QAAA,CAAA,6MAAA;SAAA;;OAEpB,CAAA,EAAA,gBAAA,YAAA;AAEA,cAAM,IAAS;;sCAEW,YAAA,QAAA,CAAA;;;;oCAIA,YAAY,QAAQ,CAAC;;;;;;;;;SAU9C,CAAC,CAAA;;;;;EAIT,CAAC"}
|