backupscript/src/CommandShow.php
Jens True 51f8436e9d
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Configuration refactoring with schema support.
2023-07-04 09:43:27 +00:00

48 lines
1.2 KiB
PHP

<?php
namespace App;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'show',
description: 'Show all backup entries.',
)]
class CommandShow extends Command
{
protected function configure(): void
{
$this->addArgument(
'config',
InputArgument::REQUIRED,
'Configuration file'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$sio = new SymfonyStyle($input, $output);
$sio->title('List backup entities');
try {
$app = new App((string)$input->getArgument('config'));
} catch (\Throwable $e) {
$sio->error('Configuration error: ' . $e->getMessage());
return Command::FAILURE;
}
$sio->table(
['Description', 'Source', 'Destination'],
$app->getConfig('backup')
);
$sio->success("Done");
return Command::SUCCESS;
}
}