summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2019-10-24 18:02:26 +0200
committerGitHub <noreply@github.com>2019-10-24 18:02:26 +0200
commit9d790ea60ce1d3af265dfc05b77d77bd94b801d7 (patch)
tree2b07ec259bbd2b1a4919245669900a87fa87a03b
parent40df67bc3b9b51caa24df5d220487043040d1f9a (diff)
parentcad48e38bfbfa6e3e0096caddf330d6fc8f1ffb9 (diff)
downloadzsh-9d790ea60ce1d3af265dfc05b77d77bd94b801d7.tar.gz
zsh-9d790ea60ce1d3af265dfc05b77d77bd94b801d7.tar.bz2
zsh-9d790ea60ce1d3af265dfc05b77d77bd94b801d7.zip
fabric: add task descriptions to completion (#5439)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
-rw-r--r--plugins/fabric/_fab19
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/fabric/_fab b/plugins/fabric/_fab
index 4c2e61306..89e73e58b 100644
--- a/plugins/fabric/_fab
+++ b/plugins/fabric/_fab
@@ -4,10 +4,19 @@
local curcontext=$curcontext state line
declare -A opt_args
-declare target_list
-target_list=(`fab --shortlist 2>/dev/null || fab --complete 2>/dev/null`)
+declare -a target_list
+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
}
@@ -28,7 +37,7 @@ _arguments -w -S -C \
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
'(--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]' \
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
levels)
_describe -t commands "output levels" output_levels;;
*)
- _targets;;
+ _fab_targets;;
esac
return