First Commit
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,94 @@
|
||||
# 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
|
||||
|
||||
_sf_{{ COMMAND_NAME }}() {
|
||||
|
||||
# Use the default completion for shell redirect operators.
|
||||
for w in '>' '>>' '&>' '<'; do
|
||||
if [[ $w = "${COMP_WORDS[COMP_CWORD-1]}" ]]; then
|
||||
compopt -o filenames
|
||||
COMPREPLY=($(compgen -f -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Use newline as only separator to allow space in completion values
|
||||
local IFS=$'\n'
|
||||
local sf_cmd="${COMP_WORDS[0]}"
|
||||
|
||||
# for an alias, get the real script behind it
|
||||
sf_cmd_type=$(type -t $sf_cmd)
|
||||
if [[ $sf_cmd_type == "alias" ]]; then
|
||||
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
|
||||
elif [[ $sf_cmd_type == "file" ]]; then
|
||||
sf_cmd=$(type -p $sf_cmd)
|
||||
fi
|
||||
|
||||
if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local cur prev words cword
|
||||
_get_comp_words_by_ref -n := cur prev words cword
|
||||
|
||||
local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-a{{ VERSION }}")
|
||||
for w in ${words[@]}; do
|
||||
w="${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
|
||||
completecmd+=("-i$w")
|
||||
fi
|
||||
done
|
||||
|
||||
local sfcomplete
|
||||
if sfcomplete=$(SHELL_VERBOSITY=0 ${completecmd[@]} 2>&1); then
|
||||
local quote suggestions
|
||||
quote=${cur:0:1}
|
||||
|
||||
# Use single quotes by default if suggestions contains backslash (FQCN)
|
||||
if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then
|
||||
quote=\'
|
||||
fi
|
||||
|
||||
if [ "$quote" == \' ]; then
|
||||
# single quotes: no additional escaping (does not accept ' in values)
|
||||
suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)
|
||||
elif [ "$quote" == \" ]; then
|
||||
# double quotes: double escaping for \ $ ` "
|
||||
suggestions=$(for s in $sfcomplete; do
|
||||
s=${s//\\/\\\\}
|
||||
s=${s//\$/\\\$}
|
||||
s=${s//\`/\\\`}
|
||||
s=${s//\"/\\\"}
|
||||
printf $'%q%q%q\n' "$quote" "$s" "$quote";
|
||||
done)
|
||||
else
|
||||
# no quotes: double escaping
|
||||
suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)
|
||||
fi
|
||||
COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))
|
||||
__ltrim_colon_completions "$cur"
|
||||
else
|
||||
if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then
|
||||
>&2 echo
|
||||
>&2 echo $sfcomplete
|
||||
fi
|
||||
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _sf_{{ COMMAND_NAME }} {{ COMMAND_NAME }}
|
||||
@@ -0,0 +1,29 @@
|
||||
# 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
|
||||
|
||||
function _sf_{{ COMMAND_NAME }}
|
||||
set sf_cmd (commandline -o)
|
||||
set c (count (commandline -oc))
|
||||
|
||||
set completecmd "$sf_cmd[1]" "_complete" "--no-interaction" "-sfish" "-a{{ VERSION }}"
|
||||
|
||||
for i in $sf_cmd
|
||||
if [ $i != "" ]
|
||||
set completecmd $completecmd "-i$i"
|
||||
end
|
||||
end
|
||||
|
||||
set completecmd $completecmd "-c$c"
|
||||
|
||||
set sfcomplete (env SHELL_VERBOSITY=0 $completecmd)
|
||||
|
||||
for i in $sfcomplete
|
||||
echo $i
|
||||
end
|
||||
end
|
||||
|
||||
complete -c '{{ COMMAND_NAME }}' -a '(_sf_{{ COMMAND_NAME }})' -f
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#compdef {{ COMMAND_NAME }}
|
||||
|
||||
# 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 {{ COMMAND_NAME }}
|
||||
#
|
||||
# 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_{{ COMMAND_NAME }}() {
|
||||
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., {{ COMMAND_NAME }} -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 -a{{ VERSION }} -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 SHELL_VERBOSITY=0 ${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_{{ COMMAND_NAME }} {{ COMMAND_NAME }}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Console\ArgumentResolver\ArgumentResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\BackedEnumValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\BuiltinTypeValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\DateTimeValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\DefaultValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\InputFileValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\MapInputValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\ServiceValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\UidValueResolver;
|
||||
use Symfony\Component\Console\ArgumentResolver\ValueResolver\VariadicValueResolver;
|
||||
use Symfony\Component\Console\EventListener\ErrorListener;
|
||||
use Symfony\Component\Dotenv\Command\DebugCommand as DotenvDebugCommand;
|
||||
|
||||
return static function (ContainerConfigurator $container) {
|
||||
$container->services()
|
||||
->set('console.error_listener', ErrorListener::class)
|
||||
->args([
|
||||
service('logger')->nullOnInvalid(),
|
||||
])
|
||||
->tag('kernel.event_subscriber')
|
||||
->tag('monolog.logger', ['channel' => 'console'])
|
||||
|
||||
->set('console.command.dotenv_debug', DotenvDebugCommand::class)
|
||||
->args([
|
||||
param('kernel.environment'),
|
||||
param('kernel.project_dir'),
|
||||
])
|
||||
->tag('console.command')
|
||||
|
||||
->set('console.argument_resolver', ArgumentResolver::class)
|
||||
->public()
|
||||
->args([
|
||||
abstract_arg('argument value resolvers'),
|
||||
abstract_arg('named argument value resolvers'),
|
||||
])
|
||||
|
||||
->set('console.argument_resolver.backed_enum', BackedEnumValueResolver::class)
|
||||
->tag('console.argument_value_resolver', ['priority' => 100, 'name' => BackedEnumValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.uid', UidValueResolver::class)
|
||||
->tag('console.argument_value_resolver', ['priority' => 100, 'name' => UidValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.input_file', InputFileValueResolver::class)
|
||||
->tag('console.argument_value_resolver', ['priority' => 100, 'name' => InputFileValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.builtin_type', BuiltinTypeValueResolver::class)
|
||||
->tag('console.argument_value_resolver', ['priority' => 100, 'name' => BuiltinTypeValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.datetime', DateTimeValueResolver::class)
|
||||
->args([
|
||||
service('clock')->nullOnInvalid(),
|
||||
])
|
||||
->tag('console.argument_value_resolver', ['priority' => 100, 'name' => DateTimeValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.map_input', MapInputValueResolver::class)
|
||||
->args([
|
||||
service('console.argument_resolver.builtin_type'),
|
||||
service('console.argument_resolver.backed_enum'),
|
||||
service('console.argument_resolver.datetime'),
|
||||
service('validator')->nullOnInvalid(),
|
||||
])
|
||||
->tag('console.argument_value_resolver', ['priority' => 100, 'name' => MapInputValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.service', ServiceValueResolver::class)
|
||||
->args([
|
||||
abstract_arg('service locator, set in RegisterCommandArgumentLocatorsPass'),
|
||||
])
|
||||
->tag('console.argument_value_resolver', ['priority' => -50, 'name' => ServiceValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.default', DefaultValueResolver::class)
|
||||
->tag('console.argument_value_resolver', ['priority' => -100, 'name' => DefaultValueResolver::class])
|
||||
|
||||
->set('console.argument_resolver.variadic', VariadicValueResolver::class)
|
||||
->tag('console.argument_value_resolver', ['priority' => -150, 'name' => VariadicValueResolver::class])
|
||||
;
|
||||
};
|
||||
Reference in New Issue
Block a user