Skip to content

Commit

Permalink
[chain] Avoid overwrite chain command options with global/default opt…
Browse files Browse the repository at this point in the history
…ions (#164)

* [chain] Avoid overwrite chain command options with global/default options

* Revert "[chain] Avoid overwrite chain command options with global/default options"

This reverts commit 1096794.

* [chain] Avoid overwrite chain command options with global/default options
  • Loading branch information
enzolutions authored and jmolivas committed May 25, 2017
1 parent 9c76535 commit 40d3484
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Command/Chain/ChainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$commands = $configData['commands'];
}

$parameterOptions = $input->getOptions();
unset($parameterOptions['file']);
$chainInlineOptions = $input->getOptions();
unset($chainInlineOptions['file']);

foreach ($commands as $command) {
$moduleInputs = [];
Expand All @@ -310,11 +310,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$moduleInputs['--'.$key] = is_null($value) ? '' : $value;
}

// Get application global options
foreach ($this->getApplication()->getDefinition()->getOptions() as $option) {
$optionName = $option->getName();
if (array_key_exists($optionName, $parameterOptions)) {
$optionValue = $parameterOptions[$optionName];
if ($optionValue) {
if (array_key_exists($optionName, $chainInlineOptions)) {
$optionValue = $chainInlineOptions[$optionName];
// Set global option only if is not available in command options
if (!isset($moduleInputs['--' . $optionName]) && $optionValue) {
$moduleInputs['--' . $optionName] = $optionValue;
}
}
Expand Down

0 comments on commit 40d3484

Please sign in to comment.