summaryrefslogtreecommitdiff
path: root/completions/zsh/_podman
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2020-01-08 13:20:36 -0700
committerEd Santiago <santiago@redhat.com>2020-01-08 14:24:43 -0700
commit3b2aa033c8f6abdf93e25f9e7bed7dd596fcfe34 (patch)
treee2eb3d04745cf31ef3d0c4b5a59fe382c8dcc333 /completions/zsh/_podman
parentc99b413abbc74f6f7e126d8bca58f44a3fcd9c2d (diff)
downloadpodman-3b2aa033c8f6abdf93e25f9e7bed7dd596fcfe34.tar.gz
podman-3b2aa033c8f6abdf93e25f9e7bed7dd596fcfe34.tar.bz2
podman-3b2aa033c8f6abdf93e25f9e7bed7dd596fcfe34.zip
Usage messages: show possible option values
...in a consistent manner: ("a"|"b"|"c") This makes it possible (and easy) for zsh completion to pick those out of the --help messages and offer them as values when user hits TAB. I chose this format because it's an already-existing convention in cmd/podman/common.go. Also: removed two duplicate "default: x" messages (Cobra displays those automatically where a non-null default is specified). Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'completions/zsh/_podman')
-rw-r--r--completions/zsh/_podman19
1 files changed, 6 insertions, 13 deletions
diff --git a/completions/zsh/_podman b/completions/zsh/_podman
index 06aa92748..067eebbbb 100644
--- a/completions/zsh/_podman
+++ b/completions/zsh/_podman
@@ -111,20 +111,13 @@ _podman_find_helper() {
elif expr "$desc" : ".*[Pp]ath" >/dev/null; then
optval="path"
helper=_files
- elif [ "$flags" = "--cgroup-manager" ]; then
- optval="cgroup manager"
- helper="(cgroupfs systemd)"
- elif [ "$flags" = "--log-level" ]; then
- optval="log level"
- # 'Log messages above specified level: debug, ... (default "...")'
- # Strip off the description and all 'default' strings
- desc=${desc/Log*:/} # debug, info, ... (default "...")
- desc=${(S)desc//\(*\)/} # debug, info, ... or panic
- desc=${desc//,/} # debug info ... or panic
- desc=${desc// or / } # debug info ... panic
- desc=${desc// / } # collapse multiple spaces
+ # For messages like 'restart policy ("always"|"no"|"on-failure")
+ elif optlist=$(expr "$desc" : '.*(\(\"[^\\)]\+|[^\\)]\+\"\))' 2>/dev/null); then
+ optval=${${flags##--}//-/ } # "--log-level" => "log level"
+ optlist=${optlist//\"/} # "a"|"b"|"c" => a|b|c
+ optlist=${optlist//\|/ } # a|b|c => a b c
# FIXME: how to present values _in order_, not sorted alphabetically?
- helper="($desc)"
+ helper="($optlist)"
fi
echo "$optval:$helper"
}