Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#compdef team51

# This file is part of the Symfony package.
#
# (c) Fabien Potencier <fabien@symfony.com>
#
# For the full copyright and license information, please view
# https://symfony.com/doc/current/contributing/code/license.html

#
# zsh completions for team51
#
# References:
# - https://github.com/spf13/cobra/blob/master/zsh_completions.go
# - https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Resources/completion.bash
#
_sf_team51() {
local lastParam flagPrefix requestComp out comp
local -a completions

# The user could have moved the cursor backwards on the command-line.
# We need to trigger completion from the $CURRENT location, so we need
# to truncate the command-line ($words) up to the $CURRENT location.
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
words=("${=words[1,CURRENT]}") lastParam=${words[-1]}

# For zsh, when completing a flag with an = (e.g., team51 -n=<TAB>)
# completions must be prefixed with the flag
setopt local_options BASH_REMATCH
if [[ "${lastParam}" =~ '-.*=' ]]; then
# We are dealing with a flag with an =
flagPrefix="-P ${BASH_REMATCH}"
fi

# Prepare the command to obtain completions
requestComp="${words[0]} ${words[1]} _complete --no-interaction -szsh -a1 -c$((CURRENT-1))" i=""
for w in ${words[@]}; do
w=$(printf -- '%b' "$w")
# remove quotes from typed values
quote="${w:0:1}"
if [ "$quote" = \' ]; then
w="${w%\'}"
w="${w#\'}"
elif [ "$quote" = \" ]; then
w="${w%\"}"
w="${w#\"}"
fi
# empty values are ignored
if [ ! -z "$w" ]; then
i="${i}-i${w} "
fi
done

# Ensure at least 1 input
if [ "${i}" = "" ]; then
requestComp="${requestComp} -i\" \""
else
requestComp="${requestComp} ${i}"
fi

# Use eval to handle any environment variables and such
out=$(eval ${requestComp} 2>/dev/null)

while IFS='\n' read -r comp; do
if [ -n "$comp" ]; then
# If requested, completions are returned with a description.
# The description is preceded by a TAB character.
# For zsh's _describe, we need to use a : instead of a TAB.
# We first need to escape any : as part of the completion itself.
comp=${comp//:/\\:}
local tab=$(printf '\t')
comp=${comp//$tab/:}
completions+=${comp}
fi
done < <(printf "%s\n" "${out[@]}")

# Let inbuilt _describe handle completions
eval _describe "completions" completions $flagPrefix
return $?
}

compdef _sf_team51 team51
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"ext-gd": "*",
"amphp/http-client": "^4.6",
"phpseclib/phpseclib": "^3.0",
"symfony/console": "^4.4",
"symfony/filesystem": "^4.4",
"symfony/finder": "^4.4",
"symfony/process": "^4.4"
"symfony/console": "^v6.4",
"symfony/filesystem": "^v6.4",
"symfony/finder": "^v6.4",
"symfony/process": "^v6.4"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"config": {
"platform": {
"php": "7.4"
"php": "8.1"
}
}
}
Loading