Improve 'go help' completion

This commit is contained in:
Shohei YOSHIDA 2024-07-29 18:47:46 +09:00
parent 057d9a9940
commit f475c1322f
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 24 additions and 18 deletions

View File

@ -415,6 +415,17 @@ case $state in
'-json[prints the final go.mod/work file in JSON format]' '-json[prints the final go.mod/work file in JSON format]'
'-print[prints the final go.mod/work in its text format]' '-print[prints the final go.mod/work in its text format]'
) )
local -a mod_commands=(
'download:download modules to local cache'
'edit:edit go.mod from tools or scripts'
'graph:print module requirement graph'
'init:initialize new module in current directory'
'tidy:add missing and remove unused modules'
'vendor:make vendored copy of dependencies'
'verify:verify dependencies have expected content'
'why:explain why packages or modules are needed'
'help:get more information about a command'
)
case $words[1] in case $words[1] in
build) build)
@ -593,27 +604,15 @@ case $state in
_arguments ${list_args[@]} _arguments ${list_args[@]}
;; ;;
mod) (mod)
local -a mod_commands=(
'download:download modules to local cache'
'edit:edit go.mod from tools or scripts'
'graph:print module requirement graph'
'init:initialize new module in current directory'
'tidy:add missing and remove unused modules'
'vendor:make vendored copy of dependencies'
'verify:verify dependencies have expected content'
'why:explain why packages or modules are needed'
'help:get more information about a command'
)
_arguments \ _arguments \
"1: :{_describe 'command' mod_commands}" \ "1: :{_describe 'command' mod_commands}" \
'*:: :->args' '*:: :->args'
case $state in case $state in
args) (args)
case $words[1] in case $words[1] in
download) (download)
_arguments \ _arguments \
'-json[print a sequence of JSON objects to standard output]' \ '-json[print a sequence of JSON objects to standard output]' \
'-x[print the commands download executes]' '-x[print the commands download executes]'
@ -662,7 +661,7 @@ case $state in
esac esac
;; ;;
run) (run)
_arguments \ _arguments \
${build_flags[@]} \ ${build_flags[@]} \
'-exec[invoke the binary using xprog]:xporg' \ '-exec[invoke the binary using xprog]:xporg' \
@ -1129,11 +1128,18 @@ case $state in
'vcs:controlling version control with GOVCS' 'vcs:controlling version control with GOVCS'
) )
case "$words[2]" in
(mod)
_arguments "2: :{_describe 'command' mod_commands}"
;;
(*)
_arguments "1: :{_describe 'command' commands -- topics}" _arguments "1: :{_describe 'command' commands -- topics}"
;; ;;
esac esac
;; ;;
esac esac
;;
esac
# Local Variables: # Local Variables:
# mode: Shell-Script # mode: Shell-Script