From 9b8cad5d0c9b296afa0d71946fb64e95dab70207 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 13 Sep 2021 23:50:43 +0300 Subject: [PATCH] feat(console): add EntriesDeleteCommand #543 --- .../Commands/Entries/EntriesDeleteCommand.php | 39 +++++++++++++++++++ src/flextype/core/Console/console.php | 8 ++-- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/flextype/core/Console/Commands/Entries/EntriesDeleteCommand.php diff --git a/src/flextype/core/Console/Commands/Entries/EntriesDeleteCommand.php b/src/flextype/core/Console/Commands/Entries/EntriesDeleteCommand.php new file mode 100644 index 00000000..13e19687 --- /dev/null +++ b/src/flextype/core/Console/Commands/Entries/EntriesDeleteCommand.php @@ -0,0 +1,39 @@ +setName('entries:delete'); + $this->setDescription('Delete entry.'); + $this->addOption('id', null, InputOption::VALUE_REQUIRED, 'Unique identifier of the entry.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + + if (entries()->delete($input->getOption('id'), $data)) { + $io->success('Deleted entry ' . $input->getOption('id')); + return Command::SUCCESS; + } else { + $io->error('Entry ' . $input->getOption('id') . ' wasn\'t deleted.'); + return Command::FAILURE; + } + } +} \ No newline at end of file diff --git a/src/flextype/core/Console/console.php b/src/flextype/core/Console/console.php index 346f5961..a3b6c898 100644 --- a/src/flextype/core/Console/console.php +++ b/src/flextype/core/Console/console.php @@ -11,7 +11,9 @@ namespace Flextype; use Symfony\Component\Console\Application as ConsoleApplication; use Flextype\Console\Commands\Entries\EntriesCreateCommand; +use Flextype\Console\Commands\Entries\EntriesDeleteCommand; -$app = new ConsoleApplication(); -$app->add(new EntriesCreateCommand()); -$app->run(); \ No newline at end of file +$console = new ConsoleApplication(); +$console->add(new EntriesCreateCommand()); +$console->add(new EntriesDeleteCommand()); +$console->run(); \ No newline at end of file