Skip to content

Commit

Permalink
[Runtime] fix overriding --env|-e with single-command apps
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 11, 2021
1 parent d119a38 commit 876ad7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions SymfonyRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public function getRunner(?object $application): RunnerInterface
}

$console->setDefaultCommand($application->getName(), true);
$console->getDefinition()->addOptions($application->getDefinition()->getOptions());

return $this->getRunner($console);
}
Expand Down
9 changes: 5 additions & 4 deletions Tests/phpt/command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

require __DIR__.'/autoload.php';

return function (Command $command, InputInterface $input, OutputInterface $output, array $context) {
$command->setCode(function () use ($output, $context) {
$output->write('OK Command '.$context['SOME_VAR']);
});
$command->addOption('hello', 'e', InputOption::VALUE_REQUIRED, 'How should I greet?', 'OK');

return $command;
return $command->setCode(function () use ($input, $output, $context) {
$output->write($input->getOption('hello').' Command '.$context['SOME_VAR']);
});
};

0 comments on commit 876ad7c

Please sign in to comment.