mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 23:55:35 +08:00
change commands definition to attribute
This commit is contained in:
@@ -7,20 +7,15 @@ namespace ZM\Command;
|
||||
use Psy\Configuration;
|
||||
use Psy\Shell;
|
||||
use Psy\VersionUpdater\Checker;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use ZM\Framework;
|
||||
|
||||
#[AsCommand(name: 'repl', description: '交互式控制台')]
|
||||
class ReplCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'repl';
|
||||
|
||||
protected static $defaultDescription = '交互式控制台';
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
public function handle(): int
|
||||
{
|
||||
$config = Configuration::fromInput($input);
|
||||
$config = Configuration::fromInput($this->input);
|
||||
$config->setUpdateCheck(Checker::NEVER);
|
||||
$config->setStartupMessage('你可以使用 "help" 来查看帮助');
|
||||
|
||||
@@ -28,13 +23,13 @@ class ReplCommand extends Command
|
||||
$shell->addCommands([]); // TODO: add some great commands
|
||||
|
||||
try {
|
||||
$output->writeln(sprintf('<fg=blue>Zhamao Repl on Zhamao Framework %s</>', Framework::VERSION));
|
||||
$this->info(sprintf('<fg=blue>Zhamao Repl on Zhamao Framework %s</>', Framework::VERSION));
|
||||
$shell->run();
|
||||
} catch (\Throwable $e) {
|
||||
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
|
||||
return Command::FAILURE;
|
||||
$this->error($e->getMessage());
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user