From 485cd17002e857fa5fdd8c6f8a16ae782cfe97db Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 1 May 2022 15:47:30 +0300 Subject: [PATCH] feat(console): improve `entries:has` logic --- .../Commands/Entries/EntrieHasCommand.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php b/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php index 5c922791..d58271be 100644 --- a/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php +++ b/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php @@ -21,6 +21,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use function Thermage\div; +use function Thermage\span; +use function Thermage\renderToString; class EntriesHasCommand extends Command { @@ -33,13 +36,23 @@ class EntriesHasCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { - $io = new SymfonyStyle($input, $output); + $id = $input->getArgument('id'); - if (entries()->has($input->getArgument('id'))) { - $io->success('Entry ' . $input->getArgument('id') . ' exists'); + if (entries()->has($id)) { + $output->write( + renderToString( + div('Success: Entry [b]' . $id . '[/b] exists.', + 'bg-success px-2 py-1') + ) + ); return Command::SUCCESS; } else { - $io->error('Entry ' . $input->getArgument('id') . ' doesn\'t exists'); + $output->write( + renderToString( + div('Failure: Entry [b]' . $id . '[/b] doesn\'t exists.', + 'bg-danger px-2 py-1') + ) + ); return Command::FAILURE; } }