Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #22244 [Console] Fix passing options with defaultCommand (Jakub S…
…acha) This PR was merged into the 2.7 branch. Discussion ---------- [Console] Fix passing options with defaultCommand | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Seems like overwriting input for the default command is not needed (anymore?). I don't know where the removed comment comes from originally. Use case: i want to call default command and use options at the same time: app/console --abc=true Commits ------- 761de99 Fix passing options with defaultCommand
- Loading branch information
Showing
4 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class FooOptCommand extends Command | ||
{ | ||
public $input; | ||
public $output; | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('foo:bar') | ||
->setDescription('The foo:bar command') | ||
->setAliases(array('afoobar')) | ||
->addOption('fooopt', 'fo', InputOption::VALUE_OPTIONAL, 'fooopt description') | ||
; | ||
} | ||
|
||
protected function interact(InputInterface $input, OutputInterface $output) | ||
{ | ||
$output->writeln('interact called'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$this->input = $input; | ||
$this->output = $output; | ||
|
||
$output->writeln('called'); | ||
$output->writeln($this->input->getOption('fooopt')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters