-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Workbunny\WebmanSharedCache\Commands; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
abstract class AbstractCommand extends Command | ||
{ | ||
|
||
protected function info(OutputInterface $output, string $message): void | ||
{ | ||
$output->writeln("ℹ️ $message"); | ||
} | ||
|
||
protected function error(OutputInterface $output, string $message): int | ||
{ | ||
$output->writeln("❌ $message"); | ||
return self::FAILURE; | ||
} | ||
|
||
protected function success(OutputInterface $output, string $message): int | ||
{ | ||
$output->writeln("✅ $message"); | ||
return self::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Workbunny\WebmanSharedCache\Commands; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Workbunny\WebmanSharedCache\Cache; | ||
|
||
class WorkbunnyWebmanSharedCacheClean extends AbstractCommand | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this->setName('workbunny:shared-cache-clean') | ||
->setDescription('Remove all workbunny/webman-shared-cache caches. '); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
Cache::Clear(); | ||
return $this->success($output, "All caches removed successfully. "); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Workbunny\WebmanSharedCache\Commands; | ||
|
||
use Symfony\Component\Console\Helper\Table; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class WorkbunnyWebmanSharedCacheList extends AbstractCommand | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this->setName('workbunny:shared-cache-list') | ||
->setDescription('Show workbunny/webman-shared-cache caches list. '); | ||
|
||
$this->addOption('page', 'p', InputOption::VALUE_OPTIONAL, 'Page. ', 1); | ||
$this->addOption('size', 's', InputOption::VALUE_OPTIONAL, 'Page size. ', 20); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$page = $input->getOption('page'); | ||
$size = $input->getOption('size'); | ||
$headers = ['name', 'value']; | ||
$rows = []; | ||
// todo | ||
|
||
$table = new Table($output); | ||
$table->setHeaders($headers); | ||
$table->setRows($rows); | ||
$table->render(); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |