summaryrefslogtreecommitdiff
path: root/completions/zsh/_podman-remote
diff options
context:
space:
mode:
Diffstat (limited to 'completions/zsh/_podman-remote')
-rw-r--r--completions/zsh/_podman-remote32
1 files changed, 30 insertions, 2 deletions
diff --git a/completions/zsh/_podman-remote b/completions/zsh/_podman-remote
index a2d24af25..2d7e7a549 100644
--- a/completions/zsh/_podman-remote
+++ b/completions/zsh/_podman-remote
@@ -1,4 +1,4 @@
-#compdef _podman-remote podman-remote
+#compdef podman-remote
# zsh completion for podman-remote -*- shell-script -*-
@@ -86,7 +86,24 @@ _podman-remote()
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-remote_debug "ActiveHelp found: $comp"
+ comp="${comp[$startIndex,-1]}"
+ if [ -n "$comp" ]; then
+ compadd -x "${comp}"
+ __podman-remote_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-remote()
# 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-remote_debug "Adding completion: ${comp}"
@@ -103,6 +120,17 @@ _podman-remote()
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-remote_debug "Adding activeHelp delimiter"
+ compadd -x "--"
+ hasActiveHelp=0
+ fi
+ fi
+
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
__podman-remote_debug "Activating nospace."
noSpace="-S ''"