41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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;
 | |
| use Symfony\Component\Console\Style\SymfonyStyle;
 | |
| 
 | |
| 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
 | |
|     {
 | |
|         $io = new SymfonyStyle($input, $output);
 | |
|         $io->title('List backup entities');
 | |
| 
 | |
|         try {
 | |
|             $app = new App($input->getArgument('config'));
 | |
|         }
 | |
|         catch (\Throwable $e) {
 | |
|             $io->error('Unable to parse the YAML string: '. $e->getMessage());
 | |
|             return Command::FAILURE;
 | |
|         }
 | |
| 
 | |
|         $io->table(['Description', 'Source', 'Destination'], $app->getConfig()['backup']);
 | |
| 
 | |
|         $io->success("Done");
 | |
|         return Command::SUCCESS;
 | |
|     }
 | |
| } |