feat: streamline cli command output styles
This commit is contained in:
@@ -10,6 +10,7 @@ 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: 'app:cleanup:xml-dumps',
|
||||
@@ -26,6 +27,8 @@ class CleanupXMLDumpsCommand extends Command
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
// we look for files older than 1 week
|
||||
$maxDate = (new \DateTimeImmutable())->modify('-1 week')->getTimestamp();
|
||||
|
||||
@@ -37,7 +40,7 @@ class CleanupXMLDumpsCommand extends Command
|
||||
->map(fn (StorageAttributes $attributes) => $attributes->path())
|
||||
->toArray();
|
||||
} catch (FilesystemException $e) {
|
||||
$output->writeln('<error>'.$e->getMessage().'</error>');
|
||||
$io->error($e->getMessage());
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
@@ -47,8 +50,9 @@ class CleanupXMLDumpsCommand extends Command
|
||||
}
|
||||
|
||||
$message = 'Removed '.count($files).' outdated XML dumps';
|
||||
|
||||
$this->logger->info($message);
|
||||
$output->writeln('<info>'.$message.'</info>');
|
||||
$io->success($message);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ 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: 'app:crypto:generate-keys', description: 'Generate keypair for encryption')]
|
||||
class GenerateKeysCommand extends Command
|
||||
@@ -20,6 +21,9 @@ class GenerateKeysCommand extends Command
|
||||
{
|
||||
(new KeyPair())->generate($this->path.'/private.key', $this->path.'/public.key');
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->success('Generated keypair in '.$this->path);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user