aboutsummaryrefslogtreecommitdiff
path: root/completions/zsh/_podman
diff options
context:
space:
mode:
Diffstat (limited to 'completions/zsh/_podman')
-rw-r--r--completions/zsh/_podman32
1 files changed, 30 insertions, 2 deletions
diff --git a/completions/zsh/_podman b/completions/zsh/_podman
index 7c3d6faf3..e2d086108 100644
--- a/completions/zsh/_podman
+++ b/completions/zsh/_podman
@@ -1,4 +1,4 @@
-#compdef _podman podman
+#compdef podman
# zsh completion for podman -*- shell-script -*-
@@ -86,7 +86,24 @@ _podman()
return
fi
+ local activeHelpMarker="_activeHelp_ "
+ local endIndex=${#activeHelpMarker}
+ local startIndex=$((${#activeHelpMarker}+1))
+ local hasActiveHelp=0
while IFS='\n' read -r comp; do
+ # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
+ if [ "${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
+ __podman_debug "ActiveHelp found: $comp"
+ comp="${comp[$startIndex,-1]}"
+ if [ -n "$comp" ]; then
+ compadd -x "${comp}"
+ __podman_debug "ActiveHelp will need delimiter"
+ hasActiveHelp=1
+ fi
+
+ continue
+ fi
+
if [ -n "$comp" ]; then
# If requested, completions are returned with a description.
# The description is preceded by a TAB character.
@@ -94,7 +111,7 @@ _podman()
# We first need to escape any : as part of the completion itself.
comp=${comp//:/\\:}
- local tab=$(printf '\t')
+ local tab="$(printf '\t')"
comp=${comp//$tab/:}
__podman_debug "Adding completion: ${comp}"
@@ -103,6 +120,17 @@ _podman()
fi
done < <(printf "%s\n" "${out[@]}")
+ # Add a delimiter after the activeHelp statements, but only if:
+ # - there are completions following the activeHelp statements, or
+ # - file completion will be performed (so there will be choices after the activeHelp)
+ if [ $hasActiveHelp -eq 1 ]; then
+ if [ ${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
+ __podman_debug "Adding activeHelp delimiter"
+ compadd -x "--"
+ hasActiveHelp=0
+ fi
+ fi
+
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
__podman_debug "Activating nospace."
noSpace="-S ''"