From ac4b107f194898ab1ef2b9962b413c641f943066 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 20 Sep 2021 23:47:29 +0300 Subject: [PATCH] feat(console): use args for EntriesCreateCommand #543 --- .../Commands/Entries/EntriesCreateCommand.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/flextype/core/Console/Commands/Entries/EntriesCreateCommand.php b/src/flextype/core/Console/Commands/Entries/EntriesCreateCommand.php index 46032c8c..6106a227 100644 --- a/src/flextype/core/Console/Commands/Entries/EntriesCreateCommand.php +++ b/src/flextype/core/Console/Commands/Entries/EntriesCreateCommand.php @@ -10,10 +10,10 @@ declare(strict_types=1); namespace Flextype\Console\Commands\Entries; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Console\Input\InputArgument; class EntriesCreateCommand extends Command { @@ -21,21 +21,21 @@ class EntriesCreateCommand extends Command { $this->setName('entries:create'); $this->setDescription('Create entry.'); - $this->addOption('id', null, InputOption::VALUE_REQUIRED, 'Unique identifier of the entry.'); - $this->addOption('data', null, InputOption::VALUE_OPTIONAL, 'Data to create for the entry.'); + $this->addArgument('id', InputArgument::REQUIRED, 'Unique identifier of the entry.'); + $this->addArgument('data', InputArgument::OPTIONAL, 'Data to create for the entry.'); } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); - $data = $input->getOption('data') ? serializers()->json()->decode($input->getOption('data')) : []; + $data = $input->getArgument('data') ? serializers()->json()->decode($input->getArgument('data')) : []; - if (entries()->create($input->getOption('id'), $data)) { - $io->success('Entry ' . $input->getOption('id') . ' created.'); + if (entries()->create($input->getArgument('id'), $data)) { + $io->success('Entry ' . $input->getArgument('id') . ' created.'); return Command::SUCCESS; } else { - $io->error('Entry ' . $input->getOption('id') . ' wasn\'t created.'); + $io->error('Entry ' . $input->getArgument('id') . ' wasn\'t created.'); return Command::FAILURE; } }