mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
@@ -21,6 +21,7 @@ use think\console\input\Argument as InputArgument;
|
|||||||
use think\console\input\Definition as InputDefinition;
|
use think\console\input\Definition as InputDefinition;
|
||||||
use think\console\input\Option as InputOption;
|
use think\console\input\Option as InputOption;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
use think\console\output\Nothing;
|
||||||
use think\console\output\Stream;
|
use think\console\output\Stream;
|
||||||
|
|
||||||
class Console
|
class Console
|
||||||
@@ -66,24 +67,42 @@ class Console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function init()
|
public static function init($run = true)
|
||||||
{
|
{
|
||||||
// 实例化console
|
static $console;
|
||||||
$console = new self('Think Console', '0.1');
|
if (!$console) {
|
||||||
// 读取指令集
|
// 实例化console
|
||||||
if (is_file(CONF_PATH . 'command' . EXT)) {
|
$console = new self('Think Console', '0.1');
|
||||||
$commands = include CONF_PATH . 'command' . EXT;
|
// 读取指令集
|
||||||
if (is_array($commands)) {
|
if (is_file(CONF_PATH . 'command' . EXT)) {
|
||||||
foreach ($commands as $command) {
|
$commands = include CONF_PATH . 'command' . EXT;
|
||||||
if (class_exists($command) && is_subclass_of($command, "\\think\\console\\command\\Command")) {
|
if (is_array($commands)) {
|
||||||
// 注册指令
|
foreach ($commands as $command) {
|
||||||
$console->add(new $command());
|
if (class_exists($command) && is_subclass_of($command, "\\think\\console\\command\\Command")) {
|
||||||
|
// 注册指令
|
||||||
|
$console->add(new $command());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 运行
|
if ($run) {
|
||||||
$console->run();
|
// 运行
|
||||||
|
$console->run();
|
||||||
|
} else {
|
||||||
|
return $console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function call($command, array $parameters = [])
|
||||||
|
{
|
||||||
|
$console = self::init(false);
|
||||||
|
|
||||||
|
array_unshift($parameters, $command);
|
||||||
|
|
||||||
|
$input = new ConsoleInput($parameters);
|
||||||
|
|
||||||
|
$console->find($command)->run($input, new Nothing());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user