From e6c9112575a89f00d7b489ba3665d78a72a12b7e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 23 Apr 2023 20:54:51 +0800 Subject: [PATCH] add option --no-motd --- src/SPC/builder/traits/NoMotdTrait.php | 13 ------------- src/SPC/command/BaseCommand.php | 8 +++++++- src/SPC/command/ListExtCommand.php | 3 +-- 3 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 src/SPC/builder/traits/NoMotdTrait.php diff --git a/src/SPC/builder/traits/NoMotdTrait.php b/src/SPC/builder/traits/NoMotdTrait.php deleted file mode 100644 index c01164d0..00000000 --- a/src/SPC/builder/traits/NoMotdTrait.php +++ /dev/null @@ -1,13 +0,0 @@ -addOption('debug', null, null, 'Enable debug mode'); + $this->addOption('no-motd', null, null, 'Disable motd'); } public function initialize(InputInterface $input, OutputInterface $output) { + if ($input->getOption('no-motd')) { + $this->no_motd = true; + } // 注册全局错误处理器 set_error_handler(static function ($error_no, $error_msg, $error_file, $error_line) { $tips = [ @@ -58,7 +64,7 @@ abstract class BaseCommand extends Command define('DEBUG_MODE', true); } $version = ConsoleApplication::VERSION; - if (!isset($this->no_motd)) { + if (!$this->no_motd) { echo " _ _ _ _ ___| |_ __ _| |_(_) ___ _ __ | |__ _ __ / __| __/ _` | __| |/ __|____| '_ \\| '_ \\| '_ \\ diff --git a/src/SPC/command/ListExtCommand.php b/src/SPC/command/ListExtCommand.php index 4a5d8741..f12466db 100644 --- a/src/SPC/command/ListExtCommand.php +++ b/src/SPC/command/ListExtCommand.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\command; -use SPC\builder\traits\NoMotdTrait; use SPC\exception\FileSystemException; use SPC\store\Config; use Symfony\Component\Console\Attribute\AsCommand; @@ -12,7 +11,7 @@ use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('list-ext', 'List supported extensions')] class ListExtCommand extends BaseCommand { - use NoMotdTrait; + protected bool $no_motd = true; /** * @throws FileSystemException