mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-26 21:51:05 +01:00
fabric: add task descriptions to completion (#5439)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
This commit is contained in:
commit
9d790ea60c
1 changed files with 14 additions and 5 deletions
|
@ -4,10 +4,19 @@
|
||||||
local curcontext=$curcontext state line
|
local curcontext=$curcontext state line
|
||||||
declare -A opt_args
|
declare -A opt_args
|
||||||
|
|
||||||
declare target_list
|
declare -a target_list
|
||||||
target_list=(`fab --shortlist 2>/dev/null || fab --complete 2>/dev/null`)
|
target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
|
||||||
|
if (NF == 0 || NR == 1) return
|
||||||
|
if (NF < 2) print $1
|
||||||
|
else {
|
||||||
|
docstring=substr($0, index($0,$2))
|
||||||
|
gsub(":", "\\:", docstring)
|
||||||
|
print $1":"docstring
|
||||||
|
}
|
||||||
|
}')}")
|
||||||
|
|
||||||
_targets() {
|
_fab_targets() {
|
||||||
|
[[ -n "$target_list" ]] || return
|
||||||
_describe -t commands "fabric targets" target_list
|
_describe -t commands "fabric targets" target_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +37,7 @@ _arguments -w -S -C \
|
||||||
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
|
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
|
||||||
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
|
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
|
||||||
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
|
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
|
||||||
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \
|
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \
|
||||||
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
|
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
|
||||||
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
|
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
|
||||||
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
|
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
|
||||||
|
@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
|
||||||
levels)
|
levels)
|
||||||
_describe -t commands "output levels" output_levels;;
|
_describe -t commands "output levels" output_levels;;
|
||||||
*)
|
*)
|
||||||
_targets;;
|
_fab_targets;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue