add pack command

This commit is contained in:
crazywhalecc 2023-01-12 09:45:56 +08:00
parent 9867004c7d
commit 00126cb1c8
No known key found for this signature in database
GPG Key ID: 4B0FFA175E762022

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace ZM\Command\Plugin;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use ZM\Bootstrap;
use ZM\Command\Command;
use ZM\Exception\PluginException;
use ZM\Plugin\PluginManager;
#[AsCommand(name: 'plugin:pack', description: '打包插件到 Phar 格式')]
class PluginPackCommand extends Command
{
protected array $bootstrappers = [
BootStrap\RegisterLogger::class,
Bootstrap\SetInternalTimezone::class,
Bootstrap\LoadConfiguration::class,
];
protected function configure()
{
$this->addArgument('name', InputArgument::REQUIRED, '要打包的插件名称');
}
/**
* {@inheritDoc}
*/
protected function handle(): int
{
try {
PluginManager::packPlugin($this->input->getArgument('name'));
} catch (PluginException $e) {
$this->error($e->getMessage());
}
$this->output->writeln('打包插件到 Phar 格式');
return 0;
}
}