1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 05:36:54 +02:00

feat(console): add CacheDeleteCommand #543

This commit is contained in:
Awilum
2021-09-21 13:34:54 +03:00
parent 72239c8e00
commit abebcf993e
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype\Console\Commands\Cache;
use Symfony\Component\Console\Command\Command;
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 CacheDeleteCommand extends Command
{
protected function configure(): void
{
$this->setName('cache:delete');
$this->setDescription('Delete key');
$this->addArgument('key', InputArgument::REQUIRED, 'Key.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$key = $input->getArgument('key');
if (cache()->delete($key)) {
$io->success('Key ' . $key . ' deleted.');
return Command::SUCCESS;
} else {
$io->error('Key ' . $key . ' wasn\'t deleted.');
return Command::FAILURE;
}
}
}

View File

@@ -17,6 +17,7 @@ use Flextype\Console\Commands\Entries\EntriesDeleteCommand;
use Flextype\Console\Commands\Entries\EntriesCopyCommand;
use Flextype\Console\Commands\Entries\EntriesMoveCommand;
use Flextype\Console\Commands\Entries\EntriesHasCommand;
use Flextype\Console\Commands\Cache\CacheDeleteCommand;
use Flextype\Console\Commands\Cache\CacheSetCommand;
use Flextype\Console\Commands\Cache\CacheGetCommand;
use Symfony\Component\Console\Input\InputInterface;
@@ -36,6 +37,7 @@ class FlextypeConsoleApplication extends ConsoleApplication
console()->add(new EntriesFetchCommand());
console()->add(new CacheSetCommand());
console()->add(new CacheGetCommand());
console()->add(new CacheDeleteCommand());
parent::run();
}