diff --git a/src/Commands/AbstractCommand.php b/src/Commands/AbstractCommand.php index c9e2133..9da0291 100644 --- a/src/Commands/AbstractCommand.php +++ b/src/Commands/AbstractCommand.php @@ -7,18 +7,52 @@ abstract class AbstractCommand extends Command { + /** + * 兼容webman console,需重写 + * + * @var string + */ + protected static string $defaultName = ''; + /** + * 兼容webman console,需重写 + * + * @var string + */ + protected static string $defaultDescription = ''; + + /** + * 输出info + * + * @param OutputInterface $output + * @param string $message + * @return void + */ protected function info(OutputInterface $output, string $message): void { $output->writeln("ℹ️ $message"); } + /** + * 输出error + * + * @param OutputInterface $output + * @param string $message + * @return int + */ protected function error(OutputInterface $output, string $message): int { $output->writeln("❌ $message"); return self::FAILURE; } + /** + * 输出success + * + * @param OutputInterface $output + * @param string $message + * @return int + */ protected function success(OutputInterface $output, string $message): int { $output->writeln("✅ $message"); diff --git a/src/Commands/WorkbunnyWebmanSharedCacheClean.php b/src/Commands/WorkbunnyWebmanSharedCacheClean.php index ea5f1e3..a521b95 100644 --- a/src/Commands/WorkbunnyWebmanSharedCacheClean.php +++ b/src/Commands/WorkbunnyWebmanSharedCacheClean.php @@ -10,13 +10,15 @@ class WorkbunnyWebmanSharedCacheClean extends AbstractCommand { + protected static string $defaultName = 'workbunny:shared-cache-clean'; + protected static string $defaultDescription = 'Remove all workbunny/webman-shared-cache caches. '; + /** * @return void */ protected function configure(): void { - $this->setName('workbunny:shared-cache-clean') - ->setDescription('Remove all workbunny/webman-shared-cache caches. '); + $this->setName(static::$defaultName)->setDescription(static::$defaultDescription); } /** diff --git a/src/Commands/WorkbunnyWebmanSharedCacheList.php b/src/Commands/WorkbunnyWebmanSharedCacheList.php index 413e918..436b3f4 100644 --- a/src/Commands/WorkbunnyWebmanSharedCacheList.php +++ b/src/Commands/WorkbunnyWebmanSharedCacheList.php @@ -9,14 +9,15 @@ class WorkbunnyWebmanSharedCacheList extends AbstractCommand { + protected static string $defaultName = 'workbunny:shared-cache-list'; + protected static string $defaultDescription = 'Show workbunny/webman-shared-cache caches list. '; + /** * @return void */ protected function configure(): void { - $this->setName('workbunny:shared-cache-list') - ->setDescription('Show workbunny/webman-shared-cache caches list. '); - + $this->setName(static::$defaultName)->setDescription(static::$defaultDescription); $this->addOption('page', 'p', InputOption::VALUE_OPTIONAL, 'Page. ', 1); $this->addOption('size', 's', InputOption::VALUE_OPTIONAL, 'Page size. ', 20); }