In Symfony 5.4 we introduced console autocompletion for the argument names, option names and option values of any command created with the Symfony Console component. In Symfony 6.1 we're improving it with new features.
Autocompletion for Fish Shell
Contributed by Guillaume Aveline
in #43641.
Autocompletion works differently depending on your shell. Previously we only supported autocompletion in Bash shell. Starting from Symfony 6.1 we also support Fish shell, which is popular among many developers. To enable autocompletion in your Fish shell, you only need to run the following command once and then source the file:
$ php bin/console completion fish >> ~/.config/fish/completions/sf_console.fish
Completion Values in Input Definitions
Contributed by Jérôme Tamarelle
in #44948.
Autocompletion is currently based on defining a method called complete() in your command. There you can provide the possible values of nay of the command arguments and options. In Symfony 6.1 you can also define autocompletion values directly in the command input definition:
new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help', function () {
// here we return the name of all app commands
return array_keys((new ApplicationDescription($this->getApplication()))->getCommands());
}),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { // here we return an array of possible values defined somewhere return (new DescriptorHelper())->getFormats(); }),
// when using addOption() and addArgument() you can also provide autocompletion ->addArgument('shell', InputArgument::OPTIONAL, '...', null, fn () => $this->getSupportedShells())
Sponsor the Symfony project.
Zaloguj się, aby dodać komentarz
Inne posty w tej grupie

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here. 🚨 Tod

Symfony 6.4.19 has just been released. Here is the list of the most important changes since 6.4.18:
bug #59198 [Messenger] Filter out non-consumable receivers when registering ConsumeMessagesComm

Symfony 7.2.4 has just been released. Here is the list of the most important changes since 7.2.3:
bug #59198 [Messenger] Filter out non-consumable receivers when registering ConsumeMessagesComman

SymfonyLive Paris 2025, conference in French language only, will already start in 1 month with the workshops! Have a look on the topics and join us! Schedule details are available here.
📣

A few weeks ago, I had the pleasure of announcing the formation of the Symfony UX Core Team, a dedicated group working to enhance the frontend development experience within the Symfony ecosystem. Toda

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here.
Al

This week, development activity focused on new security features. The upcoming Symfony 7.3 version added support for security voters to explain their vote, improved the IsGranted attribute to allow us