mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 00:25:35 +08:00
add pack command
This commit is contained in:
41
src/ZM/Command/Plugin/PluginPackCommand.php
Normal file
41
src/ZM/Command/Plugin/PluginPackCommand.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user