function DumpCompletionCommand::execute
Overrides Command::execute
File
-
vendor/
symfony/ console/ Command/ DumpCompletionCommand.php, line 82
Class
- DumpCompletionCommand
- Dumps the completion script for the current shell.
Namespace
Symfony\Component\Console\CommandCode
protected function execute(InputInterface $input, OutputInterface $output) : int {
$commandName = basename($_SERVER['argv'][0]);
if ($input->getOption('debug')) {
$this->tailDebugLog($commandName, $output);
return 0;
}
$shell = $input->getArgument('shell') ?? self::guessShell();
$completionFile = __DIR__ . '/../Resources/completion.' . $shell;
if (!file_exists($completionFile)) {
$supportedShells = $this->getSupportedShells();
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}
if ($shell) {
$output->writeln(\sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
}
else {
$output->writeln(\sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
}
return 2;
}
$output->write(str_replace([
'{{ COMMAND_NAME }}',
'{{ VERSION }}',
], [
$commandName,
CompleteCommand::COMPLETION_API_VERSION,
], file_get_contents($completionFile)));
return 0;
}