mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +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
|
abstract class BaseCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected bool $no_motd = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输入
|
* 输入
|
||||||
*/
|
*/
|
||||||
@ -29,10 +31,14 @@ abstract class BaseCommand extends Command
|
|||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
$this->addOption('debug', null, null, 'Enable debug mode');
|
$this->addOption('debug', null, null, 'Enable debug mode');
|
||||||
|
$this->addOption('no-motd', null, null, 'Disable motd');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initialize(InputInterface $input, OutputInterface $output)
|
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) {
|
set_error_handler(static function ($error_no, $error_msg, $error_file, $error_line) {
|
||||||
$tips = [
|
$tips = [
|
||||||
@ -58,7 +64,7 @@ abstract class BaseCommand extends Command
|
|||||||
define('DEBUG_MODE', true);
|
define('DEBUG_MODE', true);
|
||||||
}
|
}
|
||||||
$version = ConsoleApplication::VERSION;
|
$version = ConsoleApplication::VERSION;
|
||||||
if (!isset($this->no_motd)) {
|
if (!$this->no_motd) {
|
||||||
echo " _ _ _ _
|
echo " _ _ _ _
|
||||||
___| |_ __ _| |_(_) ___ _ __ | |__ _ __
|
___| |_ __ _| |_(_) ___ _ __ | |__ _ __
|
||||||
/ __| __/ _` | __| |/ __|____| '_ \\| '_ \\| '_ \\
|
/ __| __/ _` | __| |/ __|____| '_ \\| '_ \\| '_ \\
|
||||||
|
|||||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\command;
|
namespace SPC\command;
|
||||||
|
|
||||||
use SPC\builder\traits\NoMotdTrait;
|
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
@ -12,7 +11,7 @@ use Symfony\Component\Console\Attribute\AsCommand;
|
|||||||
#[AsCommand('list-ext', 'List supported extensions')]
|
#[AsCommand('list-ext', 'List supported extensions')]
|
||||||
class ListExtCommand extends BaseCommand
|
class ListExtCommand extends BaseCommand
|
||||||
{
|
{
|
||||||
use NoMotdTrait;
|
protected bool $no_motd = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user