make commands lazily loaded

This commit is contained in:
sunxyw
2022-12-17 22:18:50 +08:00
parent 3806983bc2
commit 44c25f7fdd
8 changed files with 98 additions and 50 deletions

View File

@@ -32,7 +32,20 @@ abstract class Command extends \Symfony\Component\Console\Command\Command
{
$this->input = $input;
$this->output = $output;
return $this->handle();
if ($this->shouldExecute()) {
return $this->handle();
}
return self::SUCCESS;
}
/**
* 是否应该执行
*
* @return bool 返回 true 以继续执行,返回 false 以中断执行
*/
protected function shouldExecute(): bool
{
return true;
}
/**