From 2bee9842f4da4191dda5835b705c681f61541071 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 21 Sep 2021 13:25:29 +0300 Subject: [PATCH] feat(console): add CacheGetCommand #543 --- .../Commands/Cache/CacheGetCommand.php | 37 +++++++++++++++++++ .../Console/FlextypeConsoleApplication.php | 2 + 2 files changed, 39 insertions(+) create mode 100644 src/flextype/core/Console/Commands/Cache/CacheGetCommand.php diff --git a/src/flextype/core/Console/Commands/Cache/CacheGetCommand.php b/src/flextype/core/Console/Commands/Cache/CacheGetCommand.php new file mode 100644 index 00000000..73199410 --- /dev/null +++ b/src/flextype/core/Console/Commands/Cache/CacheGetCommand.php @@ -0,0 +1,37 @@ +setName('cache:get'); + $this->setDescription('Get value'); + $this->addArgument('key', InputArgument::REQUIRED, 'Key.'); + $this->addArgument('default', InputArgument::OPTIONAL, 'Default.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $key = $input->getArgument('key'); + $default = $input->getArgument('default') ?? null; + + $output->writeln(cache()->get($key, $default)); + + return Command::SUCCESS; + } +} \ No newline at end of file diff --git a/src/flextype/core/Console/FlextypeConsoleApplication.php b/src/flextype/core/Console/FlextypeConsoleApplication.php index 97beb49a..8a65f38b 100644 --- a/src/flextype/core/Console/FlextypeConsoleApplication.php +++ b/src/flextype/core/Console/FlextypeConsoleApplication.php @@ -18,6 +18,7 @@ use Flextype\Console\Commands\Entries\EntriesCopyCommand; use Flextype\Console\Commands\Entries\EntriesMoveCommand; use Flextype\Console\Commands\Entries\EntriesHasCommand; use Flextype\Console\Commands\Cache\CacheSetCommand; +use Flextype\Console\Commands\Cache\CacheGetCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -34,6 +35,7 @@ class FlextypeConsoleApplication extends ConsoleApplication console()->add(new EntriesHasCommand()); console()->add(new EntriesFetchCommand()); console()->add(new CacheSetCommand()); + console()->add(new CacheGetCommand()); parent::run(); }