@shell-shock/plugin-completions 0.2.23 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) 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-shared.cjs +303 -0
  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-shared.mjs +303 -0
  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-shared.cjs +319 -0
  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} +81 -181
  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-shared.cjs +281 -0
  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-shared.mjs +281 -0
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/helpers/complete-command.cjs +2 -7
  91. package/dist/helpers/complete-command.d.cts +2 -2
  92. package/dist/helpers/complete-command.d.cts.map +1 -1
  93. package/dist/helpers/complete-command.d.mts +2 -2
  94. package/dist/helpers/complete-command.d.mts.map +1 -1
  95. package/dist/helpers/complete-command.mjs +2 -7
  96. package/dist/helpers/complete-command.mjs.map +1 -1
  97. package/dist/helpers/index.cjs +1 -1
  98. package/dist/helpers/index.d.cts +2 -2
  99. package/dist/helpers/index.d.mts +2 -2
  100. package/dist/helpers/index.mjs +2 -2
  101. package/dist/index.cjs +245 -59
  102. package/dist/index.d.cts.map +1 -1
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +246 -60
  105. package/dist/index.mjs.map +1 -1
  106. package/package.json +148 -37
  107. package/dist/components/bash-command.cjs +0 -273
  108. package/dist/components/bash-command.d.cts +0 -10
  109. package/dist/components/bash-command.d.cts.map +0 -1
  110. package/dist/components/bash-command.d.mts +0 -10
  111. package/dist/components/bash-command.d.mts.map +0 -1
  112. package/dist/components/bash-command.mjs +0 -273
  113. package/dist/components/bash-command.mjs.map +0 -1
  114. package/dist/components/fish-command.cjs +0 -403
  115. package/dist/components/fish-command.d.cts +0 -10
  116. package/dist/components/fish-command.d.cts.map +0 -1
  117. package/dist/components/fish-command.d.mts +0 -10
  118. package/dist/components/fish-command.d.mts.map +0 -1
  119. package/dist/components/fish-command.mjs +0 -403
  120. package/dist/components/fish-command.mjs.map +0 -1
  121. package/dist/components/powershell-command.cjs +0 -419
  122. package/dist/components/powershell-command.d.cts +0 -10
  123. package/dist/components/powershell-command.d.cts.map +0 -1
  124. package/dist/components/powershell-command.d.mts +0 -10
  125. package/dist/components/powershell-command.d.mts.map +0 -1
  126. package/dist/components/powershell-command.mjs.map +0 -1
  127. package/dist/components/zsh-command.cjs +0 -384
  128. package/dist/components/zsh-command.d.cts +0 -10
  129. package/dist/components/zsh-command.d.cts.map +0 -1
  130. package/dist/components/zsh-command.d.mts +0 -10
  131. package/dist/components/zsh-command.d.mts.map +0 -1
  132. package/dist/components/zsh-command.mjs +0 -384
  133. package/dist/components/zsh-command.mjs.map +0 -1
@@ -1,403 +0,0 @@
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
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
- let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
6
- let _stryke_path = require("@stryke/path");
7
- let _alloy_js_core = require("@alloy-js/core");
8
- let _alloy_js_typescript = require("@alloy-js/typescript");
9
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
- let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
11
- let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
12
- let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
13
- let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
14
- let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
15
-
16
- //#region src/components/fish-command.tsx
17
- /**
18
- * The Fish Completions commands' handler wrapper for the Shell Shock project.
19
- */
20
- function FishCompletionsCommand() {
21
- const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
22
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
23
- get path() {
24
- return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "command.ts");
25
- },
26
- imports: {
27
- "node:os": ["os"],
28
- "node:fs/promises": ["readFile", "writeFile"]
29
- },
30
- builtinImports: { "shell-shock:console": [
31
- "colors",
32
- "writeLine",
33
- "success",
34
- "warn",
35
- "stripAnsi"
36
- ] },
37
- get children() {
38
- return [
39
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Fish completions command." }),
40
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
41
- "export": true,
42
- name: "FishCompletionsOptions",
43
- get children() {
44
- return [
45
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
46
- heading: "The path to write the completion script to.",
47
- get children() {
48
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.fish\` extension will be used.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
49
- get type() {
50
- return _powerlines_deepkit_vendor_type.ReflectionKind.string;
51
- },
52
- get defaultValue() {
53
- return `${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.fish`;
54
- }
55
- })];
56
- }
57
- }),
58
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
59
- name: "script",
60
- optional: true,
61
- type: "string | true"
62
- }),
63
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
64
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
65
- heading: "The Fish configuration file to append the completion script to.",
66
- get children() {
67
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the Fish configuration file include: \\n- \`~/.config/fish/config.fish\`` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
68
- get type() {
69
- return _powerlines_deepkit_vendor_type.ReflectionKind.string;
70
- },
71
- defaultValue: "~/.config/fish/config.fish"
72
- })];
73
- }
74
- }),
75
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
76
- name: "config",
77
- optional: true,
78
- type: "string | true"
79
- })
80
- ];
81
- }
82
- }),
83
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
84
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions fish\\` command." }),
85
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
86
- "export": true,
87
- "default": true,
88
- async: true,
89
- name: "handler",
90
- parameters: [{
91
- name: "options",
92
- type: "FishCompletionsOptions"
93
- }],
94
- get children() {
95
- return [
96
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
97
- "const": true,
98
- name: "completions",
99
- type: "string",
100
- get initializer() {
101
- return _alloy_js_core.code`# fish completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
102
-
103
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug
104
- set -l file "$BASH_COMP_DEBUG_FILE"
105
- if test -n "$file"
106
- echo "$argv" >> $file
107
- end
108
- end
109
-
110
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion
111
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Starting __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion"
112
-
113
- # Extract all args except the last one
114
- set -l args (commandline -opc)
115
- # Extract the last arg and escape it in case it is a space or wildcard
116
- set -l lastArg (string escape -- (commandline -ct))
117
-
118
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "args: $args"
119
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "last arg: $lastArg"
120
-
121
- # Build the completion request command
122
- set -l requestComp "${require_helpers_complete_command.exec} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
123
-
124
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Calling $requestComp"
125
- set -l results (eval $requestComp 2> /dev/null)
126
-
127
- # Some programs may output extra empty lines after the directive.
128
- # Let's ignore them or else it will break completion.
129
- # Ref: https://github.com/spf13/cobra/issues/1279
130
- for line in $results[-1..1]
131
- if test (string trim -- $line) = ""
132
- # Found an empty line, remove it
133
- set results $results[1..-2]
134
- else
135
- # Found non-empty line, we have our proper output
136
- break
137
- end
138
- end
139
-
140
- set -l comps $results[1..-2]
141
- set -l directiveLine $results[-1]
142
-
143
- # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
144
- # completions must be prefixed with the flag
145
- set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
146
-
147
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Comps: $comps"
148
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "DirectiveLine: $directiveLine"
149
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "flagPrefix: $flagPrefix"
150
-
151
- for comp in $comps
152
- printf "%s%s\\n" "$flagPrefix" "$comp"
153
- end
154
-
155
- printf "%s\\n" "$directiveLine"
156
- end
157
-
158
- # This function limits calls to __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion, by caching the result
159
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once
160
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Starting __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once"
161
-
162
- if test -n "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
163
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Seems like a valid result already exists, skipping __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion"
164
- return 0
165
- end
166
-
167
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result (__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion)
168
- if test -z "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
169
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No completions, probably due to a failure"
170
- return 1
171
- end
172
-
173
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Performed completions and set __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
174
- return 0
175
- end
176
-
177
- # This function is used to clear the cached result after completions are run
178
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_clear_perform_completion_once_result
179
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug ""
180
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "========= clearing previously set __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result variable =========="
181
- set --erase __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result
182
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Successfully erased the variable __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
183
- end
184
-
185
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_requires_order_preservation
186
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug ""
187
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "========= checking if order preservation is required =========="
188
-
189
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once
190
- if test -z "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
191
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Error determining if order preservation is required"
192
- return 1
193
- end
194
-
195
- set -l directive (string sub --start 2 $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result[-1])
196
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Directive is: $directive"
197
-
198
- set -l shellCompDirectiveKeepOrder ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
199
- set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
200
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Keeporder is: $keeporder"
201
-
202
- if test $keeporder -ne 0
203
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "This does require order preservation"
204
- return 0
205
- end
206
-
207
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "This doesn't require order preservation"
208
- return 1
209
- end
210
-
211
- # This function does two things:
212
- # - Obtain the completions and store them in the global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results
213
- # - Return false if file completion should be performed
214
- function __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions
215
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug ""
216
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "========= starting completion logic =========="
217
-
218
- # Start fresh
219
- set --erase __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results
220
-
221
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once
222
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completion results: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
223
-
224
- if test -z "$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result"
225
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No completion, probably due to a failure"
226
- # Might as well do file completion, in case it helps
227
- return 1
228
- end
229
-
230
- set -l directive (string sub --start 2 $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result[-1])
231
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_perform_completion_once_result[1..-2]
232
-
233
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completions are: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results"
234
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Directive is: $directive"
235
-
236
- set -l shellCompDirectiveError ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
237
- set -l shellCompDirectiveNoSpace ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
238
- set -l shellCompDirectiveNoFileComp ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
239
- set -l shellCompDirectiveFilterFileExt ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterFileExt}
240
- set -l shellCompDirectiveFilterDirs ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveFilterDirs}
241
- if test -z "$directive"
242
- set directive 0
243
- end
244
-
245
- set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
246
- if test $compErr -eq 1
247
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Received error directive: aborting."
248
- # Might as well do file completion, in case it helps
249
- return 1
250
- end
251
-
252
- set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
253
- set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
254
- if test $filefilter -eq 1; or test $dirfilter -eq 1
255
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "File extension filtering or directory filtering not supported"
256
- # Do full file completion instead
257
- return 1
258
- end
259
-
260
- set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
261
- set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
262
-
263
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "nospace: $nospace, nofiles: $nofiles"
264
-
265
- # If we want to prevent a space, or if file completion is NOT disabled,
266
- # we need to count the number of valid completions.
267
- # To do so, we will filter on prefix as the completions we have received
268
- # may not already be filtered so as to allow fish to match on different
269
- # criteria than the prefix.
270
- if test $nospace -ne 0; or test $nofiles -eq 0
271
- set -l prefix (commandline -t | string escape --style=regex)
272
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "prefix: $prefix"
273
-
274
- set -l completions (string match -r -- "^$prefix.*" $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results)
275
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results $completions
276
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Filtered completions are: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results"
277
-
278
- # Important not to quote the variable for count to work
279
- set -l numComps (count $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results)
280
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "numComps: $numComps"
281
-
282
- if test $numComps -eq 1; and test $nospace -ne 0
283
- # We must first split on \\t to get rid of the descriptions to be
284
- # able to check what the actual completion will be.
285
- # We don't need descriptions anyway since there is only a single
286
- # real completion which the shell will expand immediately.
287
- set -l split (string split --max 1 "\\t" $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results[1])
288
-
289
- # Fish won't add a space if the completion ends with any
290
- # of the following characters: @=/:.,
291
- set -l lastChar (string sub -s -1 -- $split)
292
- if not string match -r -q "[@=/:.,]" -- "$lastChar"
293
- # In other cases, to support the "nospace" directive we trick the shell
294
- # by outputting an extra, longer completion.
295
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding second completion to perform nospace directive"
296
- set --global __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results $split[1] $split[1].
297
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completions are now: $__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results"
298
- end
299
- end
300
-
301
- if test $numComps -eq 0; and test $nofiles -eq 0
302
- # To be consistent with bash and zsh, we only trigger file
303
- # completion when there are no other completions
304
- __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Requesting file completion"
305
- return 1
306
- end
307
- end
308
-
309
- return 0
310
- end
311
-
312
- # Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
313
- # so we can properly delete any completions provided by another script.
314
- # Only do this if the program can be found, or else fish may print some errors; besides,
315
- # the existing completions will only be loaded if the program can be found.
316
- if type -q "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}"
317
- # The space after the program name is essential to trigger completion for the program
318
- # and not completion of the program name itself.
319
- # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
320
- complete --do-complete "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} " > /dev/null 2>&1
321
- end
322
-
323
- # Remove any pre-existing completions for the program since we will be handling all of them.
324
- complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -e
325
- # This will get called after the two calls below and clear the cached result
326
- complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n '__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_clear_perform_completion_once_result'
327
- # The call to __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions will setup __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results
328
- # which provides the program's completion choices.
329
- # If this doesn't require order preservation, we don't use the -k flag
330
- complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n 'not __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_requires_order_preservation && __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions' -f -a '$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results'
331
- # Otherwise we use the -k flag
332
- complete -k -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n '__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_requires_order_preservation && __${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_prepare_completions' -f -a '$__${(0, _stryke_string_format_snake_case.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_comp_results'
333
- \`);`;
334
- }
335
- }),
336
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
337
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
338
- condition: _alloy_js_core.code`options.config`,
339
- get children() {
340
- return [
341
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
342
- "let": true,
343
- name: "configFilePath",
344
- type: "string",
345
- initializer: _alloy_js_core.code`options.config === true ? "~/.config/fish/config.fish" : options.config`
346
- }),
347
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
348
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
349
- condition: _alloy_js_core.code`configFilePath.startsWith("~")`,
350
- children: _alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
351
- }),
352
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
353
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
354
- "let": true,
355
- name: "configFileContent",
356
- type: "string",
357
- initializer: _alloy_js_core.code`"";`
358
- }),
359
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
360
- (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
361
- configFileContent = await readFile(configFilePath, "utf8");
362
- } catch (error) {
363
- if (error.code === "ENOENT") {
364
- // If the file doesn't exist, we can create it later when writing the completion script.
365
- warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
366
- } else {
367
- return { error };
368
- }
369
- }
370
-
371
- await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
372
-
373
- success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
374
- ];
375
- }
376
- }),
377
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
378
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
379
- condition: _alloy_js_core.code`options.script`,
380
- get children() {
381
- return _alloy_js_core.code`const outputPath = options.script === true ? "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.fish" : options.script;
382
- await writeFile(outputPath, stripAnsi(completions));
383
-
384
- success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated at \${colors.bold(outputPath)}.\`);`;
385
- }
386
- }),
387
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
388
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
389
- condition: _alloy_js_core.code`!options.config && !options.script`,
390
- children: _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
391
- writeLine(completions);
392
- writeLine(" ------------------------------------------------- ");`
393
- })
394
- ];
395
- }
396
- })
397
- ];
398
- }
399
- });
400
- }
401
-
402
- //#endregion
403
- exports.FishCompletionsCommand = FishCompletionsCommand;
@@ -1,10 +0,0 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
- //#region src/components/fish-command.d.ts
4
- /**
5
- * The Fish Completions commands' handler wrapper for the Shell Shock project.
6
- */
7
- declare function FishCompletionsCommand(): _$_alloy_js_core0.Children;
8
- //#endregion
9
- export { FishCompletionsCommand };
10
- //# sourceMappingURL=fish-command.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fish-command.d.cts","names":[],"sources":["../../src/components/fish-command.tsx"],"mappings":";;;;;;iBA+CgB,sBAAA,CAAA,GAAsB,iBAAA,CAAA,QAAA"}
@@ -1,10 +0,0 @@
1
- import * as _$_alloy_js_core0 from "@alloy-js/core";
2
-
3
- //#region src/components/fish-command.d.ts
4
- /**
5
- * The Fish Completions commands' handler wrapper for the Shell Shock project.
6
- */
7
- declare function FishCompletionsCommand(): _$_alloy_js_core0.Children;
8
- //#endregion
9
- export { FishCompletionsCommand };
10
- //# sourceMappingURL=fish-command.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fish-command.d.mts","names":[],"sources":["../../src/components/fish-command.tsx"],"mappings":";;;;;;iBA+CgB,sBAAA,CAAA,GAAsB,iBAAA,CAAA,QAAA"}