mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
add option --no-motd
This commit is contained in:
parent
f0a987ba3a
commit
e6c9112575
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
|
||||
/**
|
||||
* 仅供 Command 使用,如果使用了该 Trait,则在执行对应命令时不打印 motd
|
||||
*/
|
||||
trait NoMotdTrait
|
||||
{
|
||||
protected bool $no_motd = true;
|
||||
}
|
||||
@ -13,6 +13,8 @@ use ZM\Logger\ConsoleLogger;
|
||||
|
||||
abstract class BaseCommand extends Command
|
||||
{
|
||||
protected bool $no_motd = false;
|
||||
|
||||
/**
|
||||
* 输入
|
||||
*/
|
||||
@ -29,10 +31,14 @@ abstract class BaseCommand extends Command
|
||||
{
|
||||
parent::__construct($name);
|
||||
$this->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 " _ _ _ _
|
||||
___| |_ __ _| |_(_) ___ _ __ | |__ _ __
|
||||
/ __| __/ _` | __| |/ __|____| '_ \\| '_ \\| '_ \\
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user