mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-27 18:42:20 +00:00
Zsh completions: use #compdef <program>
This means zsh scripts can't be sourced, but they can be automatically loaded from files which is the standard way of doing it.
This commit is contained in:
@@ -86,7 +86,7 @@ complete -F _comptest -o bashdefault -o default comptest
|
||||
|
||||
it("generates correct zsh completion script", function()
|
||||
assert.equal([=[
|
||||
compdef _comptest comptest
|
||||
#compdef comptest
|
||||
|
||||
_comptest() {
|
||||
local context state state_descr line
|
||||
@@ -179,6 +179,8 @@ _comptest_admin_cmds() {
|
||||
)
|
||||
_describe "command" commands
|
||||
}
|
||||
|
||||
_comptest
|
||||
]=], get_output("completion zsh"))
|
||||
end)
|
||||
|
||||
|
@@ -1409,7 +1409,7 @@ end
|
||||
function Parser:get_zsh_complete()
|
||||
self._basename = base_name(self._name)
|
||||
assert(self:_is_shell_safe())
|
||||
local buf = {("compdef _%s %s\n"):format(self._basename, self._basename)}
|
||||
local buf = {("#compdef %s\n"):format(self._basename)}
|
||||
local cmds_buf = {}
|
||||
table.insert(buf, "_" .. self._basename .. "() {")
|
||||
if #self._commands > 0 then
|
||||
@@ -1425,7 +1425,7 @@ function Parser:get_zsh_complete()
|
||||
if #cmds_buf > 0 then
|
||||
result = result .. "\n" .. table.concat(cmds_buf, "\n")
|
||||
end
|
||||
return result .. "\n"
|
||||
return result .. "\n\n_" .. self._basename .. "\n"
|
||||
end
|
||||
|
||||
local function fish_escape(string)
|
||||
|
Reference in New Issue
Block a user