catchAdmin/extend/catcher/command/Tools/CompressPackageCommand.php

41 lines
944 B
PHP
Raw Normal View History

2019-12-16 17:25:40 +08:00
<?php
declare (strict_types = 1);
2020-04-29 15:06:13 +08:00
namespace catcher\command\Tools;
2019-12-16 17:25:40 +08:00
2020-04-30 14:51:32 +08:00
use catcher\library\Compress;
2019-12-16 17:25:40 +08:00
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
2020-07-11 16:12:17 +08:00
/**
* 打包模块
*
* Class CompressPackageCommand
* @package catcher\command\Tools
*/
2019-12-17 09:03:32 +08:00
class CompressPackageCommand extends Command
2019-12-16 17:25:40 +08:00
{
protected function configure()
{
// 指令配置
2020-07-11 16:12:17 +08:00
$this->setName('catch:unpack ')
->addArgument('module', Argument::REQUIRED, 'module name')
->setDescription('compress module to zip');
2019-12-16 17:25:40 +08:00
}
protected function execute(Input $input, Output $output)
{
2020-07-11 16:12:17 +08:00
$package = $this->input->getArgument('module');
2019-12-16 17:25:40 +08:00
2019-12-17 09:03:32 +08:00
try {
2020-04-30 14:51:32 +08:00
(new Compress())->moduleToZip($package);
} catch (\Exception $e) {
2020-07-11 16:12:17 +08:00
exit($output->error($e->getMessage()));
2020-04-29 17:35:29 +08:00
}
2019-12-17 09:03:32 +08:00
2020-04-30 14:51:32 +08:00
$output->info($package . ' zip successfully~');
2019-12-16 17:25:40 +08:00
}
}