40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace AeonDumpManager\Command;
|
|
|
|
use AeonDumpManager\Service\DumpService;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
#[AsCommand(
|
|
name: 'aeon:dump:create',
|
|
description: 'Create a new SQL dump',
|
|
)]
|
|
class DumpCreateCommand extends Command
|
|
{
|
|
public function __construct(private readonly DumpService $dumpService)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
try {
|
|
$dumpFile = $this->dumpService->createSync();
|
|
} catch (\Throwable $exception) {
|
|
$io->error($exception->getMessage());
|
|
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
$io->success(sprintf('Dump created: %s', $dumpFile->filename));
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|