Allow adding file as argument in restore
This commit is contained in:
parent
b7c7a8929e
commit
7a4cc21f8e
@ -29,21 +29,24 @@ class RestoreDatabase extends Command
|
|||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||||
|
$this->addArgument('file', InputArgument::OPTIONAL, 'Backup file name');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$question = $this->getHelper('question');
|
$question = $this->getHelper('question');
|
||||||
$db = $this->getDatabaseName($input, $output);
|
$db = $this->getDatabaseName($input, $output);
|
||||||
|
$fileName = $input->getArgument('file');
|
||||||
$finder = new Finder();
|
if (!$fileName){
|
||||||
$finder->in(__DIR__ . '/../..');
|
$finder = new Finder();
|
||||||
$files = [sprintf('%s_backup.sql', $db)];
|
$finder->in(__DIR__ . '/../..');
|
||||||
foreach ($finder->files()->name('*_backup.sql') as $file) {
|
$files = [sprintf('%s_backup.sql', $db)];
|
||||||
$files[] = $file->getFilename();
|
foreach ($finder->files()->name('*_backup.sql') as $file) {
|
||||||
|
$files[] = $file->getFilename();
|
||||||
|
}
|
||||||
|
$selectQuestion = new ChoiceQuestion('Backup name (*_backup.sql): ', $files);
|
||||||
|
$fileName = $question->ask($input, $output, $selectQuestion);
|
||||||
}
|
}
|
||||||
$selectQuestion = new ChoiceQuestion('Backup name (*_backup.sql): ', $files);
|
|
||||||
$fileName = $question->ask($input, $output, $selectQuestion);
|
|
||||||
|
|
||||||
$this->bs->restore($db, $fileName);
|
$this->bs->restore($db, $fileName);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user