8000 [Runtime] fix overriding --env|-e with single-command apps · symfony/symfony@25fb2f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 25fb2f7

Browse files
[Runtime] fix overriding --env|-e with single-command apps
1 parent 1fac9ee commit 25fb2f7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Symfony/Component/Runtime/SymfonyRuntime.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function getRunner(?object $application): RunnerInterface
131131
}
132132

133133
$console->setDefaultCommand($application->getName(), true);
134+
$console->getDefinition()->addOptions($application->getDefinition()->getOptions());
134135

135136
return $this->getRunner($console);
136137
}

src/Symfony/Component/Runtime/Tests/phpt/command.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
use Symfony\Component\Console\Command\Command;
44
use Symfony\Component\Console\Input\InputInterface;
5+
use Symfony\Component\Console\Input\InputOption;
56
use Symfony\Component\Console\Output\OutputInterface;
67

78
require __DIR__.'/autoload.php';
89

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

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

0 commit comments

Comments
 (0)
0