Skip to content

Commit

Permalink
[yaml:merge] Improvide interactive UI (#2971)
Browse files Browse the repository at this point in the history
  • Loading branch information
enzolutions authored Nov 21, 2016
1 parent f79509f commit b048645
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Command/DevelDumperCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DevelDumperCommand extends Command
* DevelDumperCommand constructor.
*/
public function __construct(
DevelDumperPluginManager $develDumperPluginManager
DevelDumperPluginManager $develDumperPluginManager = null
) {
$this->develDumperPluginManager = $develDumperPluginManager;

Expand Down
17 changes: 12 additions & 5 deletions src/Command/Yaml/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$dumper = new Dumper();

$final_yaml = array();
$yaml_destination = $input->getArgument('yaml-destination');
$yaml_destination = realpath($input->getArgument('yaml-destination'));
$yaml_files = $input->getArgument('yaml-files');

if (count($yaml_files) < 2) {
Expand Down Expand Up @@ -158,15 +158,22 @@ protected function interact(InputInterface $input, OutputInterface $output)
$yaml_files = array();

while (true) {
// Set the string key based on among files provided
if(count($yaml_files) >= 2) {
$questionStringKey = 'commands.yaml.merge.questions.other-file';
}
else {
$questionStringKey = 'commands.yaml.merge.questions.file';
}

$yaml_file = $io->ask(
$this->trans('commands.yaml.merge.questions.file'),
$this->trans($questionStringKey),
'',
function ($file) use ($yaml_files, $io) {
if (count($yaml_files) < 2 && empty($file)) {
$io->error($this->trans('commands.yaml.merge.questions.invalid-file'));

return false;
} elseif (in_array($file, $yaml_files)) {
} elseif (!empty($file) && in_array($file, $yaml_files)) {
$io->error(
sprintf($this->trans('commands.yaml.merge.questions.file-already-added'), $file)
);
Expand All @@ -185,7 +192,7 @@ function ($file) use ($yaml_files, $io) {
}

if ($yaml_file) {
$yaml_files[] = $yaml_file;
$yaml_files[] = realpath($yaml_file);
}
}

Expand Down

0 comments on commit b048645

Please sign in to comment.