mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +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,8 +67,10 @@ class Console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function init()
|
public static function init($run = true)
|
||||||
{
|
{
|
||||||
|
static $console;
|
||||||
|
if (!$console) {
|
||||||
// 实例化console
|
// 实例化console
|
||||||
$console = new self('Think Console', '0.1');
|
$console = new self('Think Console', '0.1');
|
||||||
// 读取指令集
|
// 读取指令集
|
||||||
@@ -82,8 +85,24 @@ class Console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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