2023-05-26 11:47:40 +00:00
|
|
|
<?php
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
2023-05-31 09:00:20 +00:00
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
2023-05-26 11:47:40 +00:00
|
|
|
|
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
use Symfony\Component\Yaml\Exception\ParseException;
|
|
|
|
|
|
|
|
class CommandShow extends Command
|
|
|
|
{
|
|
|
|
static $defaultName = "show";
|
|
|
|
static $defaultDescription = "Show all backup entries";
|
|
|
|
|
|
|
|
protected function configure(): void
|
|
|
|
{
|
|
|
|
$this->addArgument('config', InputArgument::OPTIONAL, 'Configuration file', "config.yml");
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
{
|
2023-05-31 09:00:20 +00:00
|
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$io->title('List backup entities');
|
|
|
|
|
2023-05-26 11:47:40 +00:00
|
|
|
try {
|
2023-05-31 14:34:35 +00:00
|
|
|
$app = new App($input->getArgument('config'));
|
|
|
|
}
|
|
|
|
catch (\Throwable $e) {
|
2023-05-31 09:00:20 +00:00
|
|
|
$io->error('Unable to parse the YAML string: '. $e->getMessage());
|
2023-05-26 13:04:15 +00:00
|
|
|
return Command::FAILURE;
|
2023-05-26 11:47:40 +00:00
|
|
|
}
|
|
|
|
|
2023-05-31 14:34:35 +00:00
|
|
|
$io->table(['Description', 'Source', 'Destination'], $app->getConfig()['backup']);
|
2023-05-31 09:00:20 +00:00
|
|
|
|
|
|
|
$io->success("Done");
|
2023-05-26 11:47:40 +00:00
|
|
|
return Command::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|