@shell-shock/plugin-completions 0.4.15 → 0.4.16
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 +6 -120
- package/dist/components/bash-config-command.mjs +6 -119
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +5 -105
- package/dist/components/bash-script-command.mjs +5 -104
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +13 -77
- package/dist/components/bash-shared.mjs +13 -76
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +6 -120
- package/dist/components/fish-config-command.mjs +6 -119
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +4 -104
- package/dist/components/fish-script-command.mjs +4 -103
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +77 -141
- package/dist/components/fish-shared.mjs +77 -140
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/index.cjs +1 -26
- package/dist/components/index.mjs +1 -14
- package/dist/components/powershell-config-command.cjs +6 -116
- package/dist/components/powershell-config-command.mjs +6 -115
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +4 -104
- package/dist/components/powershell-script-command.mjs +4 -103
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +37 -101
- package/dist/components/powershell-shared.mjs +37 -100
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +6 -120
- package/dist/components/zsh-config-command.mjs +6 -119
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +6 -108
- package/dist/components/zsh-script-command.mjs +6 -107
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +42 -106
- package/dist/components/zsh-shared.mjs +42 -105
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +1 -10
- package/dist/helpers/complete-command.mjs +1 -8
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/completion-directive-constants.cjs +1 -16
- package/dist/helpers/completion-directive-constants.mjs +1 -14
- package/dist/helpers/completion-directive-constants.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -6
- package/dist/helpers/index.mjs +1 -4
- package/dist/index.cjs +1 -303
- package/dist/index.mjs +1 -301
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -4
- package/dist/types/index.mjs +1 -3
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/shell-type.cjs +1 -12
- package/dist/types/shell-type.mjs +1 -10
- package/dist/types/shell-type.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zsh-script-command.mjs","names":[],"sources":["../../src/components/zsh-script-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function ZshScriptCompletionsCommand() {\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(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"script\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Script command.\" />\n <InterfaceDeclaration export name=\"ZshScriptCompletionsOptions\">\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 zsh script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.zsh\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n const\n name=\"scriptPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? \\`\\${path}.zsh\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Zsh script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Zsh completion script has been generated at \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\"#compdef ${bin.value} \");\n writeLine(\"#compdef _${name.value} ${bin.value}\");\n writeLine(\"\");\n writeLine(\"# Zsh completion for ${getAppTitle(context)}\");\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\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":"zsh-script-command.mjs","names":[],"sources":["../../src/components/zsh-script-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function ZshScriptCompletionsCommand() {\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(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"script\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Script command.\" />\n <InterfaceDeclaration export name=\"ZshScriptCompletionsOptions\">\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 zsh script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.zsh\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n const\n name=\"scriptPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? \\`\\${path}.zsh\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Zsh script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Zsh completion script has been generated at \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\"#compdef ${bin.value} \");\n writeLine(\"#compdef _${name.value} ${bin.value}\");\n writeLine(\"\");\n writeLine(\"# Zsh completion for ${getAppTitle(context)}\");\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\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":"6zBAgCA,SAAS,GAAmC,CAC5C,IAAO,EAAA,GAAA,CACA,EAAA,MAAA,EAAA,EAAA,CAAA,CACL,EAAA,MAAA,EAAA,EAAA,MAAA,CAAA,CACA,OAAO,EAAkB,EAAgB,CAC3C,IAAQ,MAAC,CACH,OAAG,EAAY,EAAO,UAAY,cAAA,MAAA,SAAA,aAAA,EAExC,QAAa,gBAEX,YAAA,CAAA,OAAA,CACI,mBAAmB,CAAA,WAAc,YAAW,CAChD,YAAA,CAAA,oBAAA,4BAAA,CACF,CACE,eAAgB,CAAA,QAAA,6CAEhB,CACA,IAAM,UAAO,aAEP,QAAC,oDACJ,CAAA,CAAA,EAAA,EAAA,CACC,OAAM,GACJ,KAAA,8BACA,IAAC,UAAY,CACZ,MAAI,CAAA,EAAA,EAAA,CACJ,QAAO,6LACP,IAAO,UAAG,CACZ,OAAA,EAAA,EAAA,CACQ,IAAA,MAAA,CACG,OAAK,EAAA,SAEP,aAAc,GAClB,CAAA,EAEN,CAAA,CAAA,EAAgB,EAAA,CACd,KAAU,UACV,SAAA,GACI,KAAC,UACN,CAAA,CAAA,EAEA,CAAC,CAAE,EAAC,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACH,QAAS,8DACV,CAAC,CAAE,EAAgB,EAAK,CACvB,OAAG,GACH,QAAO,GACP,MAAC,GACD,KAAA,UACD,IAAA,YAAS,CACT,MAAM,CAAA,CACN,KAAA,UACC,KAAA,8BACA,QAAA,KACA,CAAA,CACI,KAAE,OACN,KAAU,SACR,QAAA,IAAA,EAAA,MAAA,mBACC,CAAC,EAEJ,IAAI,UAAW,CACb,MAAC,CAAA,EAAA,EAAA,CACD,UAAA,CAAA,2BACE,IAAI,UAAQ,CACZ,MAAO,CAAA,EAAO,EAAA,CACd,MAAa,GACf,KAAA,aACA,KAAA,SACD,YAAY,CAAW,iDACrB,CAAA,CAAA,MAAA,CAAA,qEAAA,EAAA,EAAA,CAAA;;wBAEO,EAAU,EAAA,CAAA,wEAAA,CAAA,EAEjB,CAAC,CAAA,EAAmB,EAAa,CACjC,IAAA,UAAA,CACA,MAAU,EAAC;;kCAEE,EAAW,MAAA;mCACrB,EAAA,MAAA,GAAA,EAAA,MAAA;;8CAEO,EAAA,EAAA,CAAA;;;;;;;;;;4GAcd,CAAC,CAAC,EAEN,CAAC"}
|
|
@@ -1,83 +1,35 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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/zsh-shared.tsx
|
|
16
|
-
/**
|
|
17
|
-
* The Zsh Completions generation for the Shell Shock project.
|
|
18
|
-
*/
|
|
19
|
-
function ZshCompletionsShared() {
|
|
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", "zsh", "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
|
-
"const": true,
|
|
46
|
-
"export": true,
|
|
47
|
-
name: "SHELL_COMPLETIONS",
|
|
48
|
-
get initializer() {
|
|
49
|
-
return _alloy_js_core.code` \`__${name.value}_debug() {
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../helpers/complete-command.cjs`),t=require(`../helpers/completion-directive-constants.cjs`);require(`../helpers/index.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@shell-shock/core/plugin-utils`),i=require(`@alloy-js/core`),a=require(`@alloy-js/typescript`),o=require(`@powerlines/plugin-alloy/core`),s=require(`@powerlines/plugin-alloy/core/contexts/context`),c=require(`@powerlines/plugin-alloy/typescript`),l=require(`@stryke/path`),u=require(`@stryke/string-format/snake-case`);function d(){let d=(0,s.usePowerlines)(),f=(0,i.computed)(()=>(0,r.getAppBin)(d)),p=(0,i.computed)(()=>(0,u.snakeCase)(f.value));return(0,n.createComponent)(c.TypescriptFile,{get path(){return(0,l.joinPaths)(d.entryPath,`completions`,`zsh`,`shared.ts`)},builtinImports:{console:[`white`,`green`,`red`,`bold`,`cyan`,`gray`,`magenta`,`magentaBright`,`greenBright`,`redBright`,`cyanBright`,`dim`]},get children(){return[(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(a.VarDeclaration,{const:!0,export:!0,name:`SHELL_COMPLETIONS`,get initializer(){return i.code` \`__${p.value}_debug() {
|
|
50
2
|
local file="$BASH_COMP_DEBUG_FILE"
|
|
51
3
|
if [[ -n \\\${file} ]]; then
|
|
52
4
|
echo "$*" >> "\\\${file}"
|
|
53
5
|
fi
|
|
54
6
|
}
|
|
55
7
|
|
|
56
|
-
_${
|
|
57
|
-
local shellCompDirectiveError=${
|
|
58
|
-
local shellCompDirectiveNoSpace=${
|
|
59
|
-
local shellCompDirectiveNoFileComp=${
|
|
60
|
-
local shellCompDirectiveFilterFileExt=${
|
|
61
|
-
local shellCompDirectiveFilterDirs=${
|
|
62
|
-
local shellCompDirectiveKeepOrder=${
|
|
8
|
+
_${p.value}() {
|
|
9
|
+
local shellCompDirectiveError=${t.CompletionDirective.CompletionDirectiveError}
|
|
10
|
+
local shellCompDirectiveNoSpace=${t.CompletionDirective.CompletionDirectiveNoSpace}
|
|
11
|
+
local shellCompDirectiveNoFileComp=${t.CompletionDirective.CompletionDirectiveNoFileComp}
|
|
12
|
+
local shellCompDirectiveFilterFileExt=${t.CompletionDirective.CompletionDirectiveFilterFileExt}
|
|
13
|
+
local shellCompDirectiveFilterDirs=${t.CompletionDirective.CompletionDirectiveFilterDirs}
|
|
14
|
+
local shellCompDirectiveKeepOrder=${t.CompletionDirective.CompletionDirectiveKeepOrder}
|
|
63
15
|
|
|
64
16
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
65
17
|
local -a completions
|
|
66
18
|
|
|
67
|
-
__${
|
|
68
|
-
__${
|
|
19
|
+
__${p.value}_debug "\\n========= starting completion logic =========="
|
|
20
|
+
__${p.value}_debug "CURRENT: \\\${CURRENT}, words[*]: \\\${words[*]}"
|
|
69
21
|
|
|
70
22
|
# The user could have moved the cursor backwards on the command-line.
|
|
71
23
|
# We need to trigger completion from the $CURRENT location, so we need
|
|
72
24
|
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
73
25
|
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
74
26
|
words=( "\\\${=words[1,CURRENT]}" )
|
|
75
|
-
__${
|
|
27
|
+
__${p.value}_debug "Truncated words[*]: \\\${words[*]},"
|
|
76
28
|
|
|
77
29
|
lastParam=\\\${words[-1]}
|
|
78
30
|
lastChar=\\\${lastParam[-1]}
|
|
79
|
-
__${
|
|
80
|
-
# For zsh, when completing a flag with an = (e.g., ${
|
|
31
|
+
__${p.value}_debug "lastParam: \\\${lastParam}, lastChar: \\\${lastChar}"
|
|
32
|
+
# For zsh, when completing a flag with an = (e.g., ${f.value} -n=<TAB>)
|
|
81
33
|
# completions must be prefixed with the flag
|
|
82
34
|
setopt local_options BASH_REMATCH
|
|
83
35
|
if [[ "\\\${lastParam}" =~ '-.*=' ]]; then
|
|
@@ -90,7 +42,7 @@ _${name.value}() {
|
|
|
90
42
|
if [ "\\\${lastChar}" = "" ]; then
|
|
91
43
|
# If the last parameter is complete (there is a space following it)
|
|
92
44
|
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
93
|
-
__${
|
|
45
|
+
__${p.value}_debug "Adding extra empty parameter"
|
|
94
46
|
args_to_quote+=("")
|
|
95
47
|
fi
|
|
96
48
|
|
|
@@ -98,20 +50,20 @@ _${name.value}() {
|
|
|
98
50
|
local quoted_args=("\\\${(@q)args_to_quote}")
|
|
99
51
|
|
|
100
52
|
# Join the main command and the quoted arguments into a single string for eval
|
|
101
|
-
requestComp="${
|
|
53
|
+
requestComp="${e.EXEC_COMMAND} complete -- \\\${quoted_args[*]}"
|
|
102
54
|
|
|
103
|
-
__${
|
|
55
|
+
__${p.value}_debug "About to call: eval \\\${requestComp}"
|
|
104
56
|
|
|
105
57
|
# Use eval to handle any environment variables and such
|
|
106
58
|
out=$(eval \\\${requestComp} 2>/dev/null)
|
|
107
|
-
__${
|
|
59
|
+
__${p.value}_debug "completion output: \\\${out}"
|
|
108
60
|
|
|
109
61
|
# Extract the directive integer following a : from the last line
|
|
110
62
|
local lastLine
|
|
111
63
|
while IFS='\n' read -r line; do
|
|
112
64
|
lastLine=\\\${line}
|
|
113
65
|
done < <(printf "%s\n" "\\\${out[@]}")
|
|
114
|
-
__${
|
|
66
|
+
__${p.value}_debug "last line: \\\${lastLine}"
|
|
115
67
|
|
|
116
68
|
if [ "\\\${lastLine[1]}" = : ]; then
|
|
117
69
|
directive=\\\${lastLine[2,-1]}
|
|
@@ -121,16 +73,16 @@ _${name.value}() {
|
|
|
121
73
|
out=\\\${out[1,-$suffix]}
|
|
122
74
|
else
|
|
123
75
|
# There is no directive specified. Leave $out as is.
|
|
124
|
-
__${
|
|
76
|
+
__${p.value}_debug "No directive found. Setting to default"
|
|
125
77
|
directive=0
|
|
126
78
|
fi
|
|
127
79
|
|
|
128
|
-
__${
|
|
129
|
-
__${
|
|
130
|
-
__${
|
|
80
|
+
__${p.value}_debug "directive: \\\${directive}"
|
|
81
|
+
__${p.value}_debug "completions: \\\${out}"
|
|
82
|
+
__${p.value}_debug "flagPrefix: \\\${flagPrefix}"
|
|
131
83
|
|
|
132
84
|
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
133
|
-
__${
|
|
85
|
+
__${p.value}_debug "Completion received error. Ignoring completions."
|
|
134
86
|
return
|
|
135
87
|
fi
|
|
136
88
|
|
|
@@ -141,11 +93,11 @@ _${name.value}() {
|
|
|
141
93
|
while IFS='\n' read -r comp; do
|
|
142
94
|
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
143
95
|
if [ "\\\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
144
|
-
__${
|
|
96
|
+
__${p.value}_debug "ActiveHelp found: $comp"
|
|
145
97
|
comp="\\\${comp[$startIndex,-1]}"
|
|
146
98
|
if [ -n "$comp" ]; then
|
|
147
99
|
compadd -x "\\\${comp}"
|
|
148
|
-
__${
|
|
100
|
+
__${p.value}_debug "ActiveHelp will need delimiter"
|
|
149
101
|
hasActiveHelp=1
|
|
150
102
|
fi
|
|
151
103
|
continue
|
|
@@ -161,7 +113,7 @@ _${name.value}() {
|
|
|
161
113
|
local tab="$(printf '\\t')"
|
|
162
114
|
comp=\\\${comp//$tab/:}
|
|
163
115
|
|
|
164
|
-
__${
|
|
116
|
+
__${p.value}_debug "Adding completion: \\\${comp}"
|
|
165
117
|
completions+=\\\${comp}
|
|
166
118
|
lastComp=$comp
|
|
167
119
|
fi
|
|
@@ -172,19 +124,19 @@ _${name.value}() {
|
|
|
172
124
|
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
173
125
|
if [ $hasActiveHelp -eq 1 ]; then
|
|
174
126
|
if [ \\\${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
175
|
-
__${
|
|
127
|
+
__${p.value}_debug "Adding activeHelp delimiter"
|
|
176
128
|
compadd -x "--"
|
|
177
129
|
hasActiveHelp=0
|
|
178
130
|
fi
|
|
179
131
|
fi
|
|
180
132
|
|
|
181
133
|
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
182
|
-
__${
|
|
134
|
+
__${p.value}_debug "Activating nospace."
|
|
183
135
|
noSpace="-S ''"
|
|
184
136
|
fi
|
|
185
137
|
|
|
186
138
|
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
187
|
-
__${
|
|
139
|
+
__${p.value}_debug "Activating keep order."
|
|
188
140
|
keepOrder="-V"
|
|
189
141
|
fi
|
|
190
142
|
|
|
@@ -201,17 +153,17 @@ _${name.value}() {
|
|
|
201
153
|
done
|
|
202
154
|
filteringCmd+=" \\\${flagPrefix}"
|
|
203
155
|
|
|
204
|
-
__${
|
|
156
|
+
__${p.value}_debug "File filtering command: $filteringCmd"
|
|
205
157
|
_arguments '*:filename:'"$filteringCmd"
|
|
206
158
|
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
207
159
|
# File completion for directories only
|
|
208
160
|
local subdir
|
|
209
161
|
subdir="\\\${completions[1]}"
|
|
210
162
|
if [ -n "$subdir" ]; then
|
|
211
|
-
__${
|
|
163
|
+
__${p.value}_debug "Listing directories in $subdir"
|
|
212
164
|
pushd "\\\${subdir}" >/dev/null 2>&1
|
|
213
165
|
else
|
|
214
|
-
__${
|
|
166
|
+
__${p.value}_debug "Listing directories in ."
|
|
215
167
|
fi
|
|
216
168
|
|
|
217
169
|
local result
|
|
@@ -222,17 +174,17 @@ _${name.value}() {
|
|
|
222
174
|
fi
|
|
223
175
|
return $result
|
|
224
176
|
else
|
|
225
|
-
__${
|
|
177
|
+
__${p.value}_debug "Calling _describe"
|
|
226
178
|
if eval _describe $keepOrder "completions" completions -Q \\\${flagPrefix} \\\${noSpace}; then
|
|
227
|
-
__${
|
|
179
|
+
__${p.value}_debug "_describe found some completions"
|
|
228
180
|
|
|
229
181
|
# Return the success of having called _describe
|
|
230
182
|
return 0
|
|
231
183
|
else
|
|
232
|
-
__${
|
|
233
|
-
__${
|
|
184
|
+
__${p.value}_debug "_describe did not find completions."
|
|
185
|
+
__${p.value}_debug "Checking if we should do file completion."
|
|
234
186
|
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
235
|
-
__${
|
|
187
|
+
__${p.value}_debug "deactivating file completion"
|
|
236
188
|
|
|
237
189
|
# Return 0 to indicate completion is finished and prevent zsh from
|
|
238
190
|
# trying other completion algorithms (which could cause hanging).
|
|
@@ -240,7 +192,7 @@ _${name.value}() {
|
|
|
240
192
|
return 0
|
|
241
193
|
else
|
|
242
194
|
# Perform file completion
|
|
243
|
-
__${
|
|
195
|
+
__${p.value}_debug "Activating file completion"
|
|
244
196
|
|
|
245
197
|
# We must return the result of this command, so it must be the
|
|
246
198
|
# last command, or else we must store its result to return it.
|
|
@@ -251,18 +203,10 @@ _${name.value}() {
|
|
|
251
203
|
}
|
|
252
204
|
|
|
253
205
|
# don't run the completion function when being sourced or eval-ed
|
|
254
|
-
if [ "\\\${funcstack[1]}" = "_${
|
|
255
|
-
_${
|
|
206
|
+
if [ "\\\${funcstack[1]}" = "_${p.value}" ]; then
|
|
207
|
+
_${p.value}
|
|
256
208
|
fi
|
|
257
|
-
\`;
|
|
258
|
-
}
|
|
259
|
-
}),
|
|
260
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
261
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
262
|
-
"export": true,
|
|
263
|
-
"const": true,
|
|
264
|
-
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
265
|
-
initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
209
|
+
\`; `}}),(0,n.createComponent)(o.Spacing,{}),(0,n.createComponent)(a.VarDeclaration,{export:!0,const:!0,name:`SHELL_COMPLETIONS_DISPLAY`,initializer:i.code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
266
210
|
if (!line.trim()) {
|
|
267
211
|
return "";
|
|
268
212
|
}
|
|
@@ -283,12 +227,4 @@ fi
|
|
|
283
227
|
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
284
228
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
285
229
|
|
|
286
|
-
}).join("\\n"); `
|
|
287
|
-
})
|
|
288
|
-
];
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
//#endregion
|
|
294
|
-
exports.ZshCompletionsShared = ZshCompletionsShared;
|
|
230
|
+
}).join("\\n"); `})]}})}exports.ZshCompletionsShared=d;
|
|
@@ -1,82 +1,35 @@
|
|
|
1
|
-
import
|
|
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/zsh-shared.tsx
|
|
15
|
-
/**
|
|
16
|
-
* The Zsh Completions generation for the Shell Shock project.
|
|
17
|
-
*/
|
|
18
|
-
function ZshCompletionsShared() {
|
|
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", "zsh", "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
|
-
"const": true,
|
|
45
|
-
"export": true,
|
|
46
|
-
name: "SHELL_COMPLETIONS",
|
|
47
|
-
get initializer() {
|
|
48
|
-
return code` \`__${name.value}_debug() {
|
|
1
|
+
import{EXEC_COMMAND as e}from"../helpers/complete-command.mjs";import{CompletionDirective as t}from"../helpers/completion-directive-constants.mjs";import"../helpers/index.mjs";import{createComponent as n}from"@alloy-js/core/jsx-runtime";import{getAppBin as r}from"@shell-shock/core/plugin-utils";import{code as i,computed as a}from"@alloy-js/core";import{VarDeclaration as o}from"@alloy-js/typescript";import{Spacing as s}from"@powerlines/plugin-alloy/core";import{usePowerlines as c}from"@powerlines/plugin-alloy/core/contexts/context";import{TypescriptFile as l}from"@powerlines/plugin-alloy/typescript";import{joinPaths as u}from"@stryke/path";import{snakeCase as d}from"@stryke/string-format/snake-case";function f(){let f=c(),p=a(()=>r(f)),m=a(()=>d(p.value));return n(l,{get path(){return u(f.entryPath,`completions`,`zsh`,`shared.ts`)},builtinImports:{console:[`white`,`green`,`red`,`bold`,`cyan`,`gray`,`magenta`,`magentaBright`,`greenBright`,`redBright`,`cyanBright`,`dim`]},get children(){return[n(s,{}),n(o,{const:!0,export:!0,name:`SHELL_COMPLETIONS`,get initializer(){return i` \`__${m.value}_debug() {
|
|
49
2
|
local file="$BASH_COMP_DEBUG_FILE"
|
|
50
3
|
if [[ -n \\\${file} ]]; then
|
|
51
4
|
echo "$*" >> "\\\${file}"
|
|
52
5
|
fi
|
|
53
6
|
}
|
|
54
7
|
|
|
55
|
-
_${
|
|
56
|
-
local shellCompDirectiveError=${
|
|
57
|
-
local shellCompDirectiveNoSpace=${
|
|
58
|
-
local shellCompDirectiveNoFileComp=${
|
|
59
|
-
local shellCompDirectiveFilterFileExt=${
|
|
60
|
-
local shellCompDirectiveFilterDirs=${
|
|
61
|
-
local shellCompDirectiveKeepOrder=${
|
|
8
|
+
_${m.value}() {
|
|
9
|
+
local shellCompDirectiveError=${t.CompletionDirectiveError}
|
|
10
|
+
local shellCompDirectiveNoSpace=${t.CompletionDirectiveNoSpace}
|
|
11
|
+
local shellCompDirectiveNoFileComp=${t.CompletionDirectiveNoFileComp}
|
|
12
|
+
local shellCompDirectiveFilterFileExt=${t.CompletionDirectiveFilterFileExt}
|
|
13
|
+
local shellCompDirectiveFilterDirs=${t.CompletionDirectiveFilterDirs}
|
|
14
|
+
local shellCompDirectiveKeepOrder=${t.CompletionDirectiveKeepOrder}
|
|
62
15
|
|
|
63
16
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
64
17
|
local -a completions
|
|
65
18
|
|
|
66
|
-
__${
|
|
67
|
-
__${
|
|
19
|
+
__${m.value}_debug "\\n========= starting completion logic =========="
|
|
20
|
+
__${m.value}_debug "CURRENT: \\\${CURRENT}, words[*]: \\\${words[*]}"
|
|
68
21
|
|
|
69
22
|
# The user could have moved the cursor backwards on the command-line.
|
|
70
23
|
# We need to trigger completion from the $CURRENT location, so we need
|
|
71
24
|
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
72
25
|
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
73
26
|
words=( "\\\${=words[1,CURRENT]}" )
|
|
74
|
-
__${
|
|
27
|
+
__${m.value}_debug "Truncated words[*]: \\\${words[*]},"
|
|
75
28
|
|
|
76
29
|
lastParam=\\\${words[-1]}
|
|
77
30
|
lastChar=\\\${lastParam[-1]}
|
|
78
|
-
__${
|
|
79
|
-
# For zsh, when completing a flag with an = (e.g., ${
|
|
31
|
+
__${m.value}_debug "lastParam: \\\${lastParam}, lastChar: \\\${lastChar}"
|
|
32
|
+
# For zsh, when completing a flag with an = (e.g., ${p.value} -n=<TAB>)
|
|
80
33
|
# completions must be prefixed with the flag
|
|
81
34
|
setopt local_options BASH_REMATCH
|
|
82
35
|
if [[ "\\\${lastParam}" =~ '-.*=' ]]; then
|
|
@@ -89,7 +42,7 @@ _${name.value}() {
|
|
|
89
42
|
if [ "\\\${lastChar}" = "" ]; then
|
|
90
43
|
# If the last parameter is complete (there is a space following it)
|
|
91
44
|
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
92
|
-
__${
|
|
45
|
+
__${m.value}_debug "Adding extra empty parameter"
|
|
93
46
|
args_to_quote+=("")
|
|
94
47
|
fi
|
|
95
48
|
|
|
@@ -97,20 +50,20 @@ _${name.value}() {
|
|
|
97
50
|
local quoted_args=("\\\${(@q)args_to_quote}")
|
|
98
51
|
|
|
99
52
|
# Join the main command and the quoted arguments into a single string for eval
|
|
100
|
-
requestComp="${
|
|
53
|
+
requestComp="${e} complete -- \\\${quoted_args[*]}"
|
|
101
54
|
|
|
102
|
-
__${
|
|
55
|
+
__${m.value}_debug "About to call: eval \\\${requestComp}"
|
|
103
56
|
|
|
104
57
|
# Use eval to handle any environment variables and such
|
|
105
58
|
out=$(eval \\\${requestComp} 2>/dev/null)
|
|
106
|
-
__${
|
|
59
|
+
__${m.value}_debug "completion output: \\\${out}"
|
|
107
60
|
|
|
108
61
|
# Extract the directive integer following a : from the last line
|
|
109
62
|
local lastLine
|
|
110
63
|
while IFS='\n' read -r line; do
|
|
111
64
|
lastLine=\\\${line}
|
|
112
65
|
done < <(printf "%s\n" "\\\${out[@]}")
|
|
113
|
-
__${
|
|
66
|
+
__${m.value}_debug "last line: \\\${lastLine}"
|
|
114
67
|
|
|
115
68
|
if [ "\\\${lastLine[1]}" = : ]; then
|
|
116
69
|
directive=\\\${lastLine[2,-1]}
|
|
@@ -120,16 +73,16 @@ _${name.value}() {
|
|
|
120
73
|
out=\\\${out[1,-$suffix]}
|
|
121
74
|
else
|
|
122
75
|
# There is no directive specified. Leave $out as is.
|
|
123
|
-
__${
|
|
76
|
+
__${m.value}_debug "No directive found. Setting to default"
|
|
124
77
|
directive=0
|
|
125
78
|
fi
|
|
126
79
|
|
|
127
|
-
__${
|
|
128
|
-
__${
|
|
129
|
-
__${
|
|
80
|
+
__${m.value}_debug "directive: \\\${directive}"
|
|
81
|
+
__${m.value}_debug "completions: \\\${out}"
|
|
82
|
+
__${m.value}_debug "flagPrefix: \\\${flagPrefix}"
|
|
130
83
|
|
|
131
84
|
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
132
|
-
__${
|
|
85
|
+
__${m.value}_debug "Completion received error. Ignoring completions."
|
|
133
86
|
return
|
|
134
87
|
fi
|
|
135
88
|
|
|
@@ -140,11 +93,11 @@ _${name.value}() {
|
|
|
140
93
|
while IFS='\n' read -r comp; do
|
|
141
94
|
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
142
95
|
if [ "\\\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
143
|
-
__${
|
|
96
|
+
__${m.value}_debug "ActiveHelp found: $comp"
|
|
144
97
|
comp="\\\${comp[$startIndex,-1]}"
|
|
145
98
|
if [ -n "$comp" ]; then
|
|
146
99
|
compadd -x "\\\${comp}"
|
|
147
|
-
__${
|
|
100
|
+
__${m.value}_debug "ActiveHelp will need delimiter"
|
|
148
101
|
hasActiveHelp=1
|
|
149
102
|
fi
|
|
150
103
|
continue
|
|
@@ -160,7 +113,7 @@ _${name.value}() {
|
|
|
160
113
|
local tab="$(printf '\\t')"
|
|
161
114
|
comp=\\\${comp//$tab/:}
|
|
162
115
|
|
|
163
|
-
__${
|
|
116
|
+
__${m.value}_debug "Adding completion: \\\${comp}"
|
|
164
117
|
completions+=\\\${comp}
|
|
165
118
|
lastComp=$comp
|
|
166
119
|
fi
|
|
@@ -171,19 +124,19 @@ _${name.value}() {
|
|
|
171
124
|
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
172
125
|
if [ $hasActiveHelp -eq 1 ]; then
|
|
173
126
|
if [ \\\${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
174
|
-
__${
|
|
127
|
+
__${m.value}_debug "Adding activeHelp delimiter"
|
|
175
128
|
compadd -x "--"
|
|
176
129
|
hasActiveHelp=0
|
|
177
130
|
fi
|
|
178
131
|
fi
|
|
179
132
|
|
|
180
133
|
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
181
|
-
__${
|
|
134
|
+
__${m.value}_debug "Activating nospace."
|
|
182
135
|
noSpace="-S ''"
|
|
183
136
|
fi
|
|
184
137
|
|
|
185
138
|
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
186
|
-
__${
|
|
139
|
+
__${m.value}_debug "Activating keep order."
|
|
187
140
|
keepOrder="-V"
|
|
188
141
|
fi
|
|
189
142
|
|
|
@@ -200,17 +153,17 @@ _${name.value}() {
|
|
|
200
153
|
done
|
|
201
154
|
filteringCmd+=" \\\${flagPrefix}"
|
|
202
155
|
|
|
203
|
-
__${
|
|
156
|
+
__${m.value}_debug "File filtering command: $filteringCmd"
|
|
204
157
|
_arguments '*:filename:'"$filteringCmd"
|
|
205
158
|
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
206
159
|
# File completion for directories only
|
|
207
160
|
local subdir
|
|
208
161
|
subdir="\\\${completions[1]}"
|
|
209
162
|
if [ -n "$subdir" ]; then
|
|
210
|
-
__${
|
|
163
|
+
__${m.value}_debug "Listing directories in $subdir"
|
|
211
164
|
pushd "\\\${subdir}" >/dev/null 2>&1
|
|
212
165
|
else
|
|
213
|
-
__${
|
|
166
|
+
__${m.value}_debug "Listing directories in ."
|
|
214
167
|
fi
|
|
215
168
|
|
|
216
169
|
local result
|
|
@@ -221,17 +174,17 @@ _${name.value}() {
|
|
|
221
174
|
fi
|
|
222
175
|
return $result
|
|
223
176
|
else
|
|
224
|
-
__${
|
|
177
|
+
__${m.value}_debug "Calling _describe"
|
|
225
178
|
if eval _describe $keepOrder "completions" completions -Q \\\${flagPrefix} \\\${noSpace}; then
|
|
226
|
-
__${
|
|
179
|
+
__${m.value}_debug "_describe found some completions"
|
|
227
180
|
|
|
228
181
|
# Return the success of having called _describe
|
|
229
182
|
return 0
|
|
230
183
|
else
|
|
231
|
-
__${
|
|
232
|
-
__${
|
|
184
|
+
__${m.value}_debug "_describe did not find completions."
|
|
185
|
+
__${m.value}_debug "Checking if we should do file completion."
|
|
233
186
|
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
234
|
-
__${
|
|
187
|
+
__${m.value}_debug "deactivating file completion"
|
|
235
188
|
|
|
236
189
|
# Return 0 to indicate completion is finished and prevent zsh from
|
|
237
190
|
# trying other completion algorithms (which could cause hanging).
|
|
@@ -239,7 +192,7 @@ _${name.value}() {
|
|
|
239
192
|
return 0
|
|
240
193
|
else
|
|
241
194
|
# Perform file completion
|
|
242
|
-
__${
|
|
195
|
+
__${m.value}_debug "Activating file completion"
|
|
243
196
|
|
|
244
197
|
# We must return the result of this command, so it must be the
|
|
245
198
|
# last command, or else we must store its result to return it.
|
|
@@ -250,18 +203,10 @@ _${name.value}() {
|
|
|
250
203
|
}
|
|
251
204
|
|
|
252
205
|
# don't run the completion function when being sourced or eval-ed
|
|
253
|
-
if [ "\\\${funcstack[1]}" = "_${
|
|
254
|
-
_${
|
|
206
|
+
if [ "\\\${funcstack[1]}" = "_${m.value}" ]; then
|
|
207
|
+
_${m.value}
|
|
255
208
|
fi
|
|
256
|
-
\`;
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
|
-
createComponent(Spacing, {}),
|
|
260
|
-
createComponent(VarDeclaration, {
|
|
261
|
-
"export": true,
|
|
262
|
-
"const": true,
|
|
263
|
-
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
264
|
-
initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
209
|
+
\`; `}}),n(s,{}),n(o,{export:!0,const:!0,name:`SHELL_COMPLETIONS_DISPLAY`,initializer:i` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
265
210
|
if (!line.trim()) {
|
|
266
211
|
return "";
|
|
267
212
|
}
|
|
@@ -282,13 +227,5 @@ fi
|
|
|
282
227
|
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
283
228
|
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
284
229
|
|
|
285
|
-
}).join("\\n"); `
|
|
286
|
-
})
|
|
287
|
-
];
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
//#endregion
|
|
293
|
-
export { ZshCompletionsShared };
|
|
230
|
+
}).join("\\n"); `})]}})}export{f as ZshCompletionsShared};
|
|
294
231
|
//# sourceMappingURL=zsh-shared.mjs.map
|