catchAdmin/extend/catcher/command/install/InstallCatchModuleCommand.php

56 lines
1.7 KiB
PHP
Raw Normal View History

2020-02-26 09:06:35 +08:00
<?php
/**
* @filename InstallCatchModuleCommand.php
* @createdAt 2020/2/24
* @project https://github.com/yanwenwu/catch-admin
* @document http://doc.catchadmin.com
* @author JaguarJack <njphper@gmail.com>
* @copyright By CatchAdmin
* @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt
*/
2020-06-20 08:50:21 +08:00
namespace catcher\command\install;
2020-02-26 09:06:35 +08:00
2020-08-10 11:14:53 +08:00
use catchAdmin\permissions\model\Permissions;
2020-07-11 16:13:06 +08:00
use catcher\CatchAdmin;
use catcher\exceptions\FailedException;
2020-08-10 11:14:53 +08:00
use catcher\library\Composer;
2020-07-11 16:13:06 +08:00
use catcher\library\Compress;
2020-08-10 11:14:53 +08:00
use catcher\facade\FileSystem;
use catcher\library\InstallCatchModule;
use catcher\library\Zip;
2020-02-26 09:06:35 +08:00
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
2020-07-11 16:13:06 +08:00
use think\facade\Console;
2020-02-26 09:06:35 +08:00
class InstallCatchModuleCommand extends Command
{
protected function configure()
{
2020-08-10 11:14:53 +08:00
$this->setName('catch-install:module')
2020-02-26 09:06:35 +08:00
->addArgument('module', Argument::REQUIRED, 'module name')
2020-08-10 11:14:53 +08:00
->addOption('app', '-app', Option::VALUE_NONE, 'module install at [app] path')
2020-02-26 09:06:35 +08:00
->setDescription('install catch module');
}
protected function execute(Input $input, Output $output)
{
2020-08-10 11:14:53 +08:00
$module = $input->getArgument('module');
2020-07-11 16:13:06 +08:00
2020-08-10 11:14:53 +08:00
$install = (new InstallCatchModule())->setModule($module)
->setInstallPath($input->getOption('app'));
2020-02-26 09:06:35 +08:00
2020-08-10 11:14:53 +08:00
$output->info('start download module ' . $module);
2020-02-26 09:06:35 +08:00
2020-08-10 11:14:53 +08:00
if (!$install->download()) {
exit($output->error("install module [$module] failed"));
2020-07-11 21:44:39 +08:00
}
2020-02-26 09:06:35 +08:00
2020-08-10 11:14:53 +08:00
$install->install();
2020-02-26 09:06:35 +08:00
2020-08-10 11:14:53 +08:00
$output->info("install module [ $module ] successfully");
2020-07-11 16:13:06 +08:00
}
2020-02-26 09:06:35 +08:00
}