mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 16:15:34 +08:00
change commands definition to attribute
This commit is contained in:
@@ -5,18 +5,13 @@ declare(strict_types=1);
|
||||
namespace ZM\Command\Server;
|
||||
|
||||
use Swoole\Process;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[AsCommand(name: 'server:reload', description: '重载服务器')]
|
||||
class ServerReloadCommand extends ServerCommand
|
||||
{
|
||||
protected static $defaultName = 'server:reload';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setDescription('重载框架');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
parent::execute($input, $output);
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace ZM\Command\Server;
|
||||
|
||||
use OneBot\Driver\Process\ProcessManager;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -13,20 +14,20 @@ use ZM\Exception\ZMKnownException;
|
||||
use ZM\Framework;
|
||||
use ZM\Process\ProcessStateManager;
|
||||
|
||||
#[AsCommand(name: 'server:start', description: '启动服务器', aliases: ['server'])]
|
||||
class ServerStartCommand extends ServerCommand
|
||||
{
|
||||
protected static $defaultName = 'server';
|
||||
|
||||
public static function exportOptionArray(): array
|
||||
{
|
||||
$cmd = new self();
|
||||
$cmd->configure();
|
||||
return array_map(function ($x) { return $x->getDefault(); }, $cmd->getDefinition()->getOptions());
|
||||
return array_map(function ($x) {
|
||||
return $x->getDefault();
|
||||
}, $cmd->getDefinition()->getOptions());
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setAliases(['server:start']);
|
||||
$this->setDefinition([
|
||||
new InputOption('config-dir', null, InputOption::VALUE_REQUIRED, '指定其他配置文件目录'),
|
||||
new InputOption('driver', null, InputOption::VALUE_REQUIRED, '指定驱动类型'),
|
||||
@@ -40,7 +41,6 @@ class ServerStartCommand extends ServerCommand
|
||||
new InputOption('private-mode', null, null, '启动时隐藏MOTD和敏感信息'),
|
||||
new InputOption('print-process-pid', null, null, '打印所有进程的PID'),
|
||||
]);
|
||||
$this->setDescription('Run zhamao-framework | 启动框架');
|
||||
$this->setHelp('直接运行可以启动');
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Command\Server;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[AsCommand(name: 'server:status', description: '查看服务器状态')]
|
||||
class ServerStatusCommand extends ServerCommand
|
||||
{
|
||||
protected static $defaultName = 'server:status';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setDescription('查看框架的运行状态');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
parent::execute($input, $output);
|
||||
|
||||
@@ -5,19 +5,18 @@ declare(strict_types=1);
|
||||
namespace ZM\Command\Server;
|
||||
|
||||
use Swoole\Process;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZM\Process\ProcessStateManager;
|
||||
use ZM\Store\FileSystem;
|
||||
|
||||
#[AsCommand(name: 'server:stop', description: '停止服务器')]
|
||||
class ServerStopCommand extends ServerCommand
|
||||
{
|
||||
protected static $defaultName = 'server:stop';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setDescription('停止运行的框架');
|
||||
$this->setDefinition([
|
||||
new InputOption('force', 'f', InputOption::VALUE_NONE, '强制停止'),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user