Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private function processParams(array $config, array $expectedParams, array $actu
// Add the params coming from the environment values
$actualParams = array_replace($actualParams, $this->getEnvValues($envMap));

return $this->getParams($expectedParams, $actualParams);
return $this->getParams($expectedParams, $actualParams, $config);
}

private function getEnvValues(array $envMap)
Expand Down Expand Up @@ -137,7 +137,7 @@ private function processRenamedValues(array $renameMap, array $actualParams)
return $actualParams;
}

private function getParams(array $expectedParams, array $actualParams)
private function getParams(array $expectedParams, array $actualParams, array $config = array())
{
// Simply use the expectedParams value as default for the missing params.
if (!$this->io->isInteractive()) {
Expand All @@ -153,7 +153,11 @@ private function getParams(array $expectedParams, array $actualParams)

if (!$isStarted) {
$isStarted = true;
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>');
if (empty($config['comment'])) {
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>');
} else {
$this->io->write(sprintf('<comment>%s</comment>', $config['comment']));
}
}

$default = Inline::dump($message);
Expand Down
6 changes: 5 additions & 1 deletion Tests/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ private function setInteractionExpectations(array $testCase)
}

if (!empty($testCase['requested_params'])) {
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>')->shouldBeCalledTimes(1);
if (empty($testCase['config']['comment'])) {
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>')->shouldBeCalledTimes(1);
} else {
$this->io->write(sprintf('<comment>%s</comment>', $testCase['config']['comment']))->shouldBeCalledTimes(1);
}
}

foreach ($testCase['requested_params'] as $param => $settings) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
foo: bar
boolean: false
another: ~
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: 'null'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: Existing values are not asked interactively again

interactive: true

config:
comment: 'Please provide your configuration parameters'

requested_params:
boolean:
default: 'false'
input: 'false'
another:
default: 'null'
input: '"null"'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
boolean: false
another: test
nested: nested
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file is auto-generated during the composer install
parameters:
boolean: true
another: null
nested:
foo: bar
bar:
- foo
- test
- null
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: Missing keys are asked interactively

interactive: true

config:
comment: 'Please provide your configuration parameters'

requested_params:
boolean:
default: 'false'
input: 'true'
nested:
default: nested
input: '{foo: bar, bar: [foo, test, null]}'
another:
default: test
input: 'null'