@shell-shock/plugin-completions 0.2.24 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +1 -1
  2. package/dist/components/bash-config-command.cjs +132 -0
  3. package/dist/components/bash-config-command.d.cts +10 -0
  4. package/dist/components/bash-config-command.d.cts.map +1 -0
  5. package/dist/components/bash-config-command.d.mts +10 -0
  6. package/dist/components/bash-config-command.d.mts.map +1 -0
  7. package/dist/components/bash-config-command.mjs +132 -0
  8. package/dist/components/bash-config-command.mjs.map +1 -0
  9. package/dist/components/bash-script-command.cjs +106 -0
  10. package/dist/components/bash-script-command.d.cts +10 -0
  11. package/dist/components/bash-script-command.d.cts.map +1 -0
  12. package/dist/components/bash-script-command.d.mts +10 -0
  13. package/dist/components/bash-script-command.d.mts.map +1 -0
  14. package/dist/components/bash-script-command.mjs +106 -0
  15. package/dist/components/bash-script-command.mjs.map +1 -0
  16. package/dist/components/bash-shared.cjs +172 -0
  17. package/dist/components/bash-shared.d.cts +10 -0
  18. package/dist/components/bash-shared.d.cts.map +1 -0
  19. package/dist/components/bash-shared.d.mts +10 -0
  20. package/dist/components/bash-shared.d.mts.map +1 -0
  21. package/dist/components/bash-shared.mjs +172 -0
  22. package/dist/components/bash-shared.mjs.map +1 -0
  23. package/dist/components/fish-config-command.cjs +132 -0
  24. package/dist/components/fish-config-command.d.cts +10 -0
  25. package/dist/components/fish-config-command.d.cts.map +1 -0
  26. package/dist/components/fish-config-command.d.mts +10 -0
  27. package/dist/components/fish-config-command.d.mts.map +1 -0
  28. package/dist/components/fish-config-command.mjs +132 -0
  29. package/dist/components/fish-config-command.mjs.map +1 -0
  30. package/dist/components/fish-script-command.cjs +106 -0
  31. package/dist/components/fish-script-command.d.cts +10 -0
  32. package/dist/components/fish-script-command.d.cts.map +1 -0
  33. package/dist/components/fish-script-command.d.mts +10 -0
  34. package/dist/components/fish-script-command.d.mts.map +1 -0
  35. package/dist/components/fish-script-command.mjs +106 -0
  36. package/dist/components/fish-script-command.mjs.map +1 -0
  37. package/dist/components/{fish-command.cjs → fish-shared.cjs} +40 -144
  38. package/dist/components/fish-shared.d.cts +10 -0
  39. package/dist/components/fish-shared.d.cts.map +1 -0
  40. package/dist/components/fish-shared.d.mts +10 -0
  41. package/dist/components/fish-shared.d.mts.map +1 -0
  42. package/dist/components/{fish-command.mjs → fish-shared.mjs} +45 -149
  43. package/dist/components/fish-shared.mjs.map +1 -0
  44. package/dist/components/index.cjs +24 -8
  45. package/dist/components/index.d.cts +13 -5
  46. package/dist/components/index.d.mts +13 -5
  47. package/dist/components/index.mjs +13 -5
  48. package/dist/components/powershell-config-command.cjs +128 -0
  49. package/dist/components/powershell-config-command.d.cts +7 -0
  50. package/dist/components/powershell-config-command.d.cts.map +1 -0
  51. package/dist/components/powershell-config-command.d.mts +7 -0
  52. package/dist/components/powershell-config-command.d.mts.map +1 -0
  53. package/dist/components/powershell-config-command.mjs +128 -0
  54. package/dist/components/powershell-config-command.mjs.map +1 -0
  55. package/dist/components/powershell-script-command.cjs +106 -0
  56. package/dist/components/powershell-script-command.d.cts +10 -0
  57. package/dist/components/powershell-script-command.d.cts.map +1 -0
  58. package/dist/components/powershell-script-command.d.mts +10 -0
  59. package/dist/components/powershell-script-command.d.mts.map +1 -0
  60. package/dist/components/powershell-script-command.mjs +106 -0
  61. package/dist/components/powershell-script-command.mjs.map +1 -0
  62. package/dist/components/{powershell-command.cjs → powershell-shared.cjs} +40 -146
  63. package/dist/components/powershell-shared.d.cts +10 -0
  64. package/dist/components/powershell-shared.d.cts.map +1 -0
  65. package/dist/components/powershell-shared.d.mts +10 -0
  66. package/dist/components/powershell-shared.d.mts.map +1 -0
  67. package/dist/components/{powershell-command.mjs → powershell-shared.mjs} +44 -150
  68. package/dist/components/powershell-shared.mjs.map +1 -0
  69. package/dist/components/zsh-config-command.cjs +132 -0
  70. package/dist/components/zsh-config-command.d.cts +10 -0
  71. package/dist/components/zsh-config-command.d.cts.map +1 -0
  72. package/dist/components/zsh-config-command.d.mts +10 -0
  73. package/dist/components/zsh-config-command.d.mts.map +1 -0
  74. package/dist/components/zsh-config-command.mjs +132 -0
  75. package/dist/components/zsh-config-command.mjs.map +1 -0
  76. package/dist/components/zsh-script-command.cjs +111 -0
  77. package/dist/components/zsh-script-command.d.cts +10 -0
  78. package/dist/components/zsh-script-command.d.cts.map +1 -0
  79. package/dist/components/zsh-script-command.d.mts +10 -0
  80. package/dist/components/zsh-script-command.d.mts.map +1 -0
  81. package/dist/components/zsh-script-command.mjs +111 -0
  82. package/dist/components/zsh-script-command.mjs.map +1 -0
  83. package/dist/components/{zsh-command.cjs → zsh-shared.cjs} +41 -147
  84. package/dist/components/zsh-shared.d.cts +10 -0
  85. package/dist/components/zsh-shared.d.cts.map +1 -0
  86. package/dist/components/zsh-shared.d.mts +10 -0
  87. package/dist/components/zsh-shared.d.mts.map +1 -0
  88. package/dist/components/{zsh-command.mjs → zsh-shared.mjs} +45 -151
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/index.cjs +232 -68
  91. package/dist/index.d.cts.map +1 -1
  92. package/dist/index.d.mts.map +1 -1
  93. package/dist/index.mjs +232 -68
  94. package/dist/index.mjs.map +1 -1
  95. package/package.json +148 -36
  96. package/dist/components/bash-command.cjs +0 -276
  97. package/dist/components/bash-command.d.cts +0 -10
  98. package/dist/components/bash-command.d.cts.map +0 -1
  99. package/dist/components/bash-command.d.mts +0 -10
  100. package/dist/components/bash-command.d.mts.map +0 -1
  101. package/dist/components/bash-command.mjs +0 -276
  102. package/dist/components/bash-command.mjs.map +0 -1
  103. package/dist/components/fish-command.d.cts +0 -10
  104. package/dist/components/fish-command.d.cts.map +0 -1
  105. package/dist/components/fish-command.d.mts +0 -10
  106. package/dist/components/fish-command.d.mts.map +0 -1
  107. package/dist/components/fish-command.mjs.map +0 -1
  108. package/dist/components/powershell-command.d.cts +0 -10
  109. package/dist/components/powershell-command.d.cts.map +0 -1
  110. package/dist/components/powershell-command.d.mts +0 -10
  111. package/dist/components/powershell-command.d.mts.map +0 -1
  112. package/dist/components/powershell-command.mjs.map +0 -1
  113. package/dist/components/zsh-command.d.cts +0 -10
  114. package/dist/components/zsh-command.d.cts.map +0 -1
  115. package/dist/components/zsh-command.d.mts +0 -10
  116. package/dist/components/zsh-command.d.mts.map +0 -1
  117. package/dist/components/zsh-command.mjs.map +0 -1
@@ -0,0 +1,172 @@
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: ["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
+ "export": true,
33
+ "const": true,
34
+ name: "SHELL_COMPLETIONS",
35
+ get initializer() {
36
+ return _alloy_js_core.code` \`# Define shell completion directives
37
+ readonly ShellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
38
+ readonly ShellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
39
+ readonly ShellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
40
+ readonly ShellCompDirectiveFilterFileExt=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
41
+ readonly ShellCompDirectiveFilterDirs=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
42
+ readonly ShellCompDirectiveKeepOrder=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
43
+
44
+ # Function to debug completion
45
+ __${name.value}_debug() {
46
+ if [[ -n \\\${BASH_COMP_DEBUG_FILE:-} ]]; then
47
+ echo "$*" >> "\\\${BASH_COMP_DEBUG_FILE}"
48
+ fi
49
+ }
50
+
51
+ # Function to handle completions
52
+ __${name.value}_complete() {
53
+ local cur prev words cword
54
+ _get_comp_words_by_ref -n "=:" cur prev words cword
55
+
56
+ local requestComp out directive
57
+
58
+ # Build the command to get completions
59
+ requestComp="${require_helpers_complete_command.EXEC_COMMAND} complete -- \\\${words[@]:1}"
60
+
61
+ # Add an empty parameter if the last parameter is complete
62
+ if [[ -z "$cur" ]]; then
63
+ requestComp="$requestComp ''"
64
+ fi
65
+
66
+ # Get completions from the program
67
+ out=$(eval "$requestComp" 2>/dev/null)
68
+
69
+ # Extract directive if present
70
+ directive=0
71
+ if [[ "$out" == *:* ]]; then
72
+ directive=\\\${out##*:}
73
+ out=\\\${out%:*}
74
+ fi
75
+
76
+ # Process completions based on directive
77
+ if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
78
+ # Error, no completion
79
+ return
80
+ fi
81
+
82
+ # Apply directives
83
+ if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
84
+ compopt -o nospace
85
+ fi
86
+ if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
87
+ compopt -o nosort
88
+ fi
89
+ if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
90
+ compopt +o default
91
+ fi
92
+
93
+ # Handle file extension filtering
94
+ if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
95
+ local filter=""
96
+ for ext in $out; do
97
+ filter="$filter|$ext"
98
+ done
99
+ filter="\\.($filter)"
100
+ compopt -o filenames
101
+ COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
102
+ return
103
+ fi
104
+
105
+ # Handle directory filtering
106
+ if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
107
+ compopt -o dirnames
108
+ COMPREPLY=( $(compgen -d -- "$cur") )
109
+ return
110
+ fi
111
+
112
+ # Process completions
113
+ local IFS=$'\\n'
114
+ local tab=$(printf '\\t')
115
+
116
+ # Parse completions with descriptions
117
+ local completions=()
118
+ while read -r comp; do
119
+ if [[ "$comp" == *$tab* ]]; then
120
+ # Split completion and description
121
+ local value=\\\${comp%%$tab*}
122
+ local desc=\\\${comp#*$tab}
123
+ completions+=("$value")
124
+ else
125
+ completions+=("$comp")
126
+ fi
127
+ done <<< "$out"
128
+
129
+ # Return completions
130
+ COMPREPLY=( $(compgen -W "\\\${completions[*]}" -- "$cur") )
131
+ }
132
+
133
+ # Register completion function
134
+ complete -F __${name.value}_complete ${bin.value}
135
+ \`; `;
136
+ }
137
+ }),
138
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
139
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
140
+ "export": true,
141
+ "const": true,
142
+ name: "SHELL_COMPLETIONS_DISPLAY",
143
+ initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
144
+ if (!line.trim()) {
145
+ return "";
146
+ }
147
+ if (line.trim().startsWith("#")) {
148
+ return \`\${colors.dim(line)}\`;
149
+ }
150
+
151
+ return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
152
+ .replaceAll(/\\".*\\"/g, colors.cyan("$&"))
153
+ .replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g, colors.bold(colors.gray("$&")))
154
+ .replaceAll(/(readonly|complete)\\s+/g, colors.green("$&"))
155
+ .replaceAll(/(?<=(readonly|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
156
+ .replaceAll(/local\\s+/g, colors.red("$&"))
157
+ .replaceAll(/(?<=local\\s+)\\w/g, colors.bold(colors.redBright("$&")))
158
+ .replaceAll(/while\\s+/g, colors.cyan("$&"))
159
+ .replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
160
+ .replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
161
+ .replaceAll(/__\\w/g, colors.bold(colors.magentaBright("$&")))
162
+ .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
163
+
164
+ }).join("\\n"); `
165
+ })
166
+ ];
167
+ }
168
+ });
169
+ }
170
+
171
+ //#endregion
172
+ exports.BashCompletionsShared = BashCompletionsShared;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/bash-shared.d.ts
4
+ /**
5
+ * The Bash Completions generation for the Shell Shock project.
6
+ */
7
+ declare function BashCompletionsShared(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { BashCompletionsShared };
10
+ //# sourceMappingURL=bash-shared.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-shared.d.cts","names":[],"sources":["../../src/components/bash-shared.tsx"],"mappings":";;;;;;iBAiCgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/bash-shared.d.ts
4
+ /**
5
+ * The Bash Completions generation for the Shell Shock project.
6
+ */
7
+ declare function BashCompletionsShared(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { BashCompletionsShared };
10
+ //# sourceMappingURL=bash-shared.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-shared.d.mts","names":[],"sources":["../../src/components/bash-shared.tsx"],"mappings":";;;;;;iBAiCgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,172 @@
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: ["colors"] },
27
+ get children() {
28
+ return [
29
+ createComponent(Spacing, {}),
30
+ createComponent(VarDeclaration, {
31
+ "export": true,
32
+ "const": true,
33
+ name: "SHELL_COMPLETIONS",
34
+ get initializer() {
35
+ return code` \`# Define shell completion directives
36
+ readonly ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}
37
+ readonly ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}
38
+ readonly ShellCompDirectiveNoFileComp=${CompletionDirective.CompletionDirectiveNoFileComp}
39
+ readonly ShellCompDirectiveFilterFileExt=${CompletionDirective.CompletionDirectiveFilterFileExt}
40
+ readonly ShellCompDirectiveFilterDirs=${CompletionDirective.CompletionDirectiveFilterDirs}
41
+ readonly ShellCompDirectiveKeepOrder=${CompletionDirective.CompletionDirectiveKeepOrder}
42
+
43
+ # Function to debug completion
44
+ __${name.value}_debug() {
45
+ if [[ -n \\\${BASH_COMP_DEBUG_FILE:-} ]]; then
46
+ echo "$*" >> "\\\${BASH_COMP_DEBUG_FILE}"
47
+ fi
48
+ }
49
+
50
+ # Function to handle completions
51
+ __${name.value}_complete() {
52
+ local cur prev words cword
53
+ _get_comp_words_by_ref -n "=:" cur prev words cword
54
+
55
+ local requestComp out directive
56
+
57
+ # Build the command to get completions
58
+ requestComp="${EXEC_COMMAND} complete -- \\\${words[@]:1}"
59
+
60
+ # Add an empty parameter if the last parameter is complete
61
+ if [[ -z "$cur" ]]; then
62
+ requestComp="$requestComp ''"
63
+ fi
64
+
65
+ # Get completions from the program
66
+ out=$(eval "$requestComp" 2>/dev/null)
67
+
68
+ # Extract directive if present
69
+ directive=0
70
+ if [[ "$out" == *:* ]]; then
71
+ directive=\\\${out##*:}
72
+ out=\\\${out%:*}
73
+ fi
74
+
75
+ # Process completions based on directive
76
+ if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
77
+ # Error, no completion
78
+ return
79
+ fi
80
+
81
+ # Apply directives
82
+ if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
83
+ compopt -o nospace
84
+ fi
85
+ if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
86
+ compopt -o nosort
87
+ fi
88
+ if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
89
+ compopt +o default
90
+ fi
91
+
92
+ # Handle file extension filtering
93
+ if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
94
+ local filter=""
95
+ for ext in $out; do
96
+ filter="$filter|$ext"
97
+ done
98
+ filter="\\.($filter)"
99
+ compopt -o filenames
100
+ COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
101
+ return
102
+ fi
103
+
104
+ # Handle directory filtering
105
+ if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
106
+ compopt -o dirnames
107
+ COMPREPLY=( $(compgen -d -- "$cur") )
108
+ return
109
+ fi
110
+
111
+ # Process completions
112
+ local IFS=$'\\n'
113
+ local tab=$(printf '\\t')
114
+
115
+ # Parse completions with descriptions
116
+ local completions=()
117
+ while read -r comp; do
118
+ if [[ "$comp" == *$tab* ]]; then
119
+ # Split completion and description
120
+ local value=\\\${comp%%$tab*}
121
+ local desc=\\\${comp#*$tab}
122
+ completions+=("$value")
123
+ else
124
+ completions+=("$comp")
125
+ fi
126
+ done <<< "$out"
127
+
128
+ # Return completions
129
+ COMPREPLY=( $(compgen -W "\\\${completions[*]}" -- "$cur") )
130
+ }
131
+
132
+ # Register completion function
133
+ complete -F __${name.value}_complete ${bin.value}
134
+ \`; `;
135
+ }
136
+ }),
137
+ createComponent(Spacing, {}),
138
+ createComponent(VarDeclaration, {
139
+ "export": true,
140
+ "const": true,
141
+ name: "SHELL_COMPLETIONS_DISPLAY",
142
+ initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
143
+ if (!line.trim()) {
144
+ return "";
145
+ }
146
+ if (line.trim().startsWith("#")) {
147
+ return \`\${colors.dim(line)}\`;
148
+ }
149
+
150
+ return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
151
+ .replaceAll(/\\".*\\"/g, colors.cyan("$&"))
152
+ .replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g, colors.bold(colors.gray("$&")))
153
+ .replaceAll(/(readonly|complete)\\s+/g, colors.green("$&"))
154
+ .replaceAll(/(?<=(readonly|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
155
+ .replaceAll(/local\\s+/g, colors.red("$&"))
156
+ .replaceAll(/(?<=local\\s+)\\w/g, colors.bold(colors.redBright("$&")))
157
+ .replaceAll(/while\\s+/g, colors.cyan("$&"))
158
+ .replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
159
+ .replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
160
+ .replaceAll(/__\\w/g, colors.bold(colors.magentaBright("$&")))
161
+ .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
162
+
163
+ }).join("\\n"); `
164
+ })
165
+ ];
166
+ }
167
+ });
168
+ }
169
+
170
+ //#endregion
171
+ export { BashCompletionsShared };
172
+ //# sourceMappingURL=bash-shared.mjs.map
@@ -0,0 +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: [\"colors\"]\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 \\`\\${colors.dim(line)}\\`;\n }\n\n return colors.white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, colors.green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, colors.cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, colors.bold(colors.gray(\"$&\")))\n .replaceAll(/(readonly|complete)\\\\s+/g, colors.green(\"$&\"))\n .replaceAll(/(?<=(readonly|complete)\\\\s+)\\\\w/g, colors.bold(colors.greenBright(\"$&\")))\n .replaceAll(/local\\\\s+/g, colors.red(\"$&\"))\n .replaceAll(/(?<=local\\\\s+)\\\\w/g, colors.bold(colors.redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, colors.cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, colors.bold(colors.cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, colors.green(\"$&\"))\n .replaceAll(/__\\\\w/g, colors.bold(colors.magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, colors.bold(colors.magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,SAAgB,wBAAgB;;CAE9B,MAAM,MAAM,eAAe,UAAU,QAAQ,CAAC;CAC9C,MAAM,OAAO,eAAe,UAAU,IAAI,MAAM,CAAC;;EAEjD,IAAM,OAAC;AACJ,UAAA,UAAA,QAAA,WAAA,eAAA,QAAA,YAAA;;EAED,gBAAgB,EACd,SAAS,CAAC,SAAS,EACpB;EACD,IAAG,WAAS;AACV,UAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACC,UAAA;KACA,SAAA;KACA,MAAM;KACN,IAAA,cAAkB;AACjB,aAAA,IAAA;mCAC0B,oBAAC,yBAAA;qCACN,oBAAA,2BAAA;wCACtB,oBAAA,8BAAA;2CAC+B,oBAAA,iCAAA;wCACT,oBAAA,8BAAA;uCACtB,oBAAA,6BAAA;;;IAGJ,KAAI,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAyFI,KAAA,MAAe,YAAM,IAAA,MAAA;;;;;;KAI3B,UAAO;KACT,SAAa;KACjB,MAAA;;;;;;;;;;;;;;;;;;;;;;;KAuBO,CAAC;IAAC;;EAEN,CAAC"}
@@ -0,0 +1,132 @@
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: { "shell-shock:console": [
30
+ "colors",
31
+ "writeLine",
32
+ "success",
33
+ "warn"
34
+ ] },
35
+ get children() {
36
+ return [
37
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, { heading: "Options for the Fish Completions - Configuration command." }),
38
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
39
+ "export": true,
40
+ name: "FishConfigCompletionsOptions",
41
+ get children() {
42
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, {
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 (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDocDefaultValue, {
46
+ get type() {
47
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
48
+ },
49
+ defaultValue: false
50
+ });
51
+ }
52
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
53
+ name: "display",
54
+ optional: true,
55
+ type: "boolean"
56
+ })];
57
+ }
58
+ }),
59
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
60
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, { heading: "Handler logic for the \\`completions fish config\\` command." }),
61
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
62
+ "export": true,
63
+ "default": true,
64
+ async: true,
65
+ name: "handler",
66
+ parameters: [{
67
+ name: "options",
68
+ type: "FishConfigCompletionsOptions",
69
+ default: "{}"
70
+ }, {
71
+ name: "path",
72
+ type: "string",
73
+ default: `"~/.config/fish/config.fish"`
74
+ }],
75
+ get children() {
76
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
77
+ condition: _alloy_js_core.code`options.display !== true`,
78
+ get children() {
79
+ return [
80
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
81
+ "let": true,
82
+ name: "configPath",
83
+ type: "string",
84
+ initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, ".config", "fish", "config.fish");`
85
+ }),
86
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
87
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
88
+ condition: _alloy_js_core.code`configPath.startsWith("~")`,
89
+ children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
90
+ }),
91
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
92
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
93
+ "let": true,
94
+ name: "content",
95
+ type: "string",
96
+ initializer: _alloy_js_core.code`"";`
97
+ }),
98
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
99
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
100
+ content = await readFile(configPath, "utf8");
101
+ } catch (error) {
102
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
103
+ // If the file doesn't exist, we can create it later when writing the completion script.
104
+ warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
105
+ } else {
106
+ return { error };
107
+ }
108
+ }
109
+
110
+ 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 ###\`);
111
+
112
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Fish configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
113
+ ];
114
+ }
115
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
116
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
117
+ writeLine(\`### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\`);
118
+ writeLine("");
119
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
120
+ writeLine("");
121
+ writeLine(\`### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\`);
122
+ writeLine(" ------------------------------------------------- ");`;
123
+ } })];
124
+ }
125
+ })
126
+ ];
127
+ }
128
+ });
129
+ }
130
+
131
+ //#endregion
132
+ exports.FishConfigCompletionsCommand = FishConfigCompletionsCommand;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/fish-config-command.d.ts
4
+ /**
5
+ * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function FishConfigCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { FishConfigCompletionsCommand };
10
+ //# sourceMappingURL=fish-config-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-config-command.d.cts","names":[],"sources":["../../src/components/fish-config-command.tsx"],"mappings":";;;;;;iBAuCgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/fish-config-command.d.ts
4
+ /**
5
+ * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function FishConfigCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { FishConfigCompletionsCommand };
10
+ //# sourceMappingURL=fish-config-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-config-command.d.mts","names":[],"sources":["../../src/components/fish-config-command.tsx"],"mappings":";;;;;;iBAuCgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}