Skip to content

Commit

Permalink
added latest option to restore command (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Apr 3, 2017
1 parent 4db67ef commit 5de621a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Bundle/Command/RestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function configure()
'Defines which file should be restored (backup-name or absolute path to zip file).'
)
->addOption('server', 's', InputOption::VALUE_REQUIRED, 'Where should the command be called.', 'local')
->addOption('latest', null, InputOption::VALUE_NONE, 'Loads the latest file.')
->setHelp(
<<<EOT
The <info>{$this->getName()}</info> restores a backup archive.
Expand All @@ -51,10 +52,10 @@ protected function interact(InputInterface $input, OutputInterface $output)
$storage = $this->getContainer()->get('storage');
$localFiles = $storage->localListing();

if (count($localFiles) === 1) {
$input->setArgument('file', $localFiles[0]);

return;
if ($input->getOption('latest') && count($localFiles) > 0) {
return $input->setArgument('file', end($localFiles));
} elseif (count($localFiles) === 1) {
return $input->setArgument('file', $localFiles[0]);
}

$helper = $this->getHelper('question');
Expand Down

0 comments on commit 5de621a

Please sign in to comment.