mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
Merge remote-tracking branch 'luarocks/refs/pull/9/head'
This commit is contained in:
@@ -92,63 +92,94 @@ _comptest() {
|
|||||||
local context state state_descr line
|
local context state state_descr line
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
|
||||||
|
local -a options=(
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
"--completion[Output a shell completion script for the specified shell]: :(bash zsh fish)"
|
||||||
|
"*"{-v,--verbose}"[Set the verbosity level]"
|
||||||
|
{-f,--files}"[A description with illegal \"' characters]:*: :_files"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
"--completion[Output a shell completion script for the specified shell]: :(bash zsh fish)" \
|
|
||||||
"*"{-v,--verbose}"[Set the verbosity level]" \
|
|
||||||
{-f,--files}"[A description with illegal \"' characters]:*: :_files" \
|
|
||||||
": :_comptest_cmds" \
|
": :_comptest_cmds" \
|
||||||
"*:: :->args" \
|
"*:: :->args" \
|
||||||
&& return 0
|
&& return 0
|
||||||
|
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
help)
|
help)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
": :(help completion install i admin)" \
|
": :(help completion install i admin)" \
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
completion)
|
completion)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
": :(bash zsh fish)" \
|
": :(bash zsh fish)" \
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
install|i)
|
install|i)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
"--deps-mode: :(all one order none)"
|
||||||
|
"--no-doc[Install without documentation]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
"--deps-mode: :(all one order none)" \
|
|
||||||
"--no-doc[Install without documentation]" \
|
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
admin)
|
admin)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
": :_comptest_admin_cmds" \
|
": :_comptest_admin_cmds" \
|
||||||
"*:: :->args" \
|
"*:: :->args" \
|
||||||
&& return 0
|
&& return 0
|
||||||
|
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
help)
|
help)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
": :(help add remove)" \
|
": :(help add remove)" \
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
add)
|
add)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
": :_files" \
|
": :_files" \
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
remove)
|
remove)
|
||||||
|
options=(
|
||||||
|
$options
|
||||||
|
{-h,--help}"[Show this help message and exit]"
|
||||||
|
)
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
{-h,--help}"[Show this help message and exit]" \
|
$options \
|
||||||
": :_files" \
|
": :_files" \
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
@@ -1307,7 +1307,12 @@ complete -F _%s -o bashdefault -o default %s
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Parser:_zsh_arguments(buf, cmd_name, indent)
|
function Parser:_zsh_arguments(buf, cmd_name, indent)
|
||||||
table.insert(buf, (" "):rep(indent) .. "_arguments -s -S \\")
|
if self._parent then
|
||||||
|
table.insert(buf, (" "):rep(indent) .. "options=(")
|
||||||
|
table.insert(buf, (" "):rep(indent + 2) .. "$options")
|
||||||
|
else
|
||||||
|
table.insert(buf, (" "):rep(indent) .. "local -a options=(")
|
||||||
|
end
|
||||||
|
|
||||||
for _, option in ipairs(self._options) do
|
for _, option in ipairs(self._options) do
|
||||||
local line = {}
|
local line = {}
|
||||||
@@ -1336,10 +1341,13 @@ function Parser:_zsh_arguments(buf, cmd_name, indent)
|
|||||||
table.insert(line, ": :_files")
|
table.insert(line, ": :_files")
|
||||||
end
|
end
|
||||||
table.insert(line, '"')
|
table.insert(line, '"')
|
||||||
|
table.insert(buf, (" "):rep(indent + 2) .. table.concat(line))
|
||||||
table.insert(buf, (" "):rep(indent + 2) .. table.concat(line) .. " \\")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table.insert(buf, (" "):rep(indent) .. ")")
|
||||||
|
table.insert(buf, (" "):rep(indent) .. "_arguments -s -S \\")
|
||||||
|
table.insert(buf, (" "):rep(indent + 2) .. "$options \\")
|
||||||
|
|
||||||
if self._is_help_command then
|
if self._is_help_command then
|
||||||
table.insert(buf, (" "):rep(indent + 2) .. '": :(' .. self._parent:_get_commands() .. ')" \\')
|
table.insert(buf, (" "):rep(indent + 2) .. '": :(' .. self._parent:_get_commands() .. ')" \\')
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user