mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
win10下支持带颜色输出
This commit is contained in:
@@ -16,7 +16,7 @@ use think\console\helper\Formatter as FormatterHelper;
|
|||||||
use think\console\helper\Process as ProcessHelper;
|
use think\console\helper\Process as ProcessHelper;
|
||||||
use think\console\helper\Question as QuestionHelper;
|
use think\console\helper\Question as QuestionHelper;
|
||||||
use think\console\helper\Set as HelperSet;
|
use think\console\helper\Set as HelperSet;
|
||||||
use think\console\Input as ConsoleInput;
|
use think\console\Input;
|
||||||
use think\console\input\Argument as InputArgument;
|
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;
|
||||||
@@ -102,7 +102,7 @@ class Console
|
|||||||
|
|
||||||
array_unshift($parameters, $command);
|
array_unshift($parameters, $command);
|
||||||
|
|
||||||
$input = new ConsoleInput($parameters);
|
$input = new Input($parameters);
|
||||||
|
|
||||||
$console->find($command)->run($input, new Nothing());
|
$console->find($command)->run($input, new Nothing());
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ class Console
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$input = new ConsoleInput();
|
$input = new Input();
|
||||||
$output = new Output();
|
$output = new Output();
|
||||||
|
|
||||||
$this->configureIO($input, $output);
|
$this->configureIO($input, $output);
|
||||||
@@ -153,11 +153,11 @@ class Console
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行指令
|
* 执行指令
|
||||||
* @param ConsoleInput $input
|
* @param Input $input
|
||||||
* @param Output $output
|
* @param Output $output
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function doRun(ConsoleInput $input, Output $output)
|
public function doRun(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
if (true === $input->hasParameterOption(['--version', '-V'])) {
|
if (true === $input->hasParameterOption(['--version', '-V'])) {
|
||||||
$output->writeln($this->getLongVersion());
|
$output->writeln($this->getLongVersion());
|
||||||
@@ -170,7 +170,7 @@ class Console
|
|||||||
if (true === $input->hasParameterOption(['--help', '-h'])) {
|
if (true === $input->hasParameterOption(['--help', '-h'])) {
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
$name = 'help';
|
$name = 'help';
|
||||||
$input = new ConsoleInput(['help']);
|
$input = new Input(['help']);
|
||||||
} else {
|
} else {
|
||||||
$this->wantHelps = true;
|
$this->wantHelps = true;
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ class Console
|
|||||||
|
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
$name = $this->defaultCommand;
|
$name = $this->defaultCommand;
|
||||||
$input = new ConsoleInput([$this->defaultCommand]);
|
$input = new Input([$this->defaultCommand]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = $this->find($name);
|
$command = $this->find($name);
|
||||||
@@ -681,10 +681,10 @@ class Console
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置基于用户的参数和选项的输入和输出实例。
|
* 配置基于用户的参数和选项的输入和输出实例。
|
||||||
* @param ConsoleInput $input 输入实例
|
* @param Input $input 输入实例
|
||||||
* @param Output $output 输出实例
|
* @param Output $output 输出实例
|
||||||
*/
|
*/
|
||||||
protected function configureIO(ConsoleInput $input, Output $output)
|
protected function configureIO(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
if (true === $input->hasParameterOption(['--ansi'])) {
|
if (true === $input->hasParameterOption(['--ansi'])) {
|
||||||
$output->setDecorated(true);
|
$output->setDecorated(true);
|
||||||
@@ -717,22 +717,22 @@ class Console
|
|||||||
/**
|
/**
|
||||||
* 执行指令
|
* 执行指令
|
||||||
* @param Command $command 指令实例
|
* @param Command $command 指令实例
|
||||||
* @param ConsoleInput $input 输入实例
|
* @param Input $input 输入实例
|
||||||
* @param Output $output 输出实例
|
* @param Output $output 输出实例
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected function doRunCommand(Command $command, ConsoleInput $input, Output $output)
|
protected function doRunCommand(Command $command, Input $input, Output $output)
|
||||||
{
|
{
|
||||||
return $command->run($input, $output);
|
return $command->run($input, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指令的基础名称
|
* 获取指令的基础名称
|
||||||
* @param ConsoleInput $input
|
* @param Input $input
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getCommandName(ConsoleInput $input)
|
protected function getCommandName(Input $input)
|
||||||
{
|
{
|
||||||
return $input->getFirstArgument();
|
return $input->getFirstArgument();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
namespace think\console\command\make;
|
namespace think\console\command\make;
|
||||||
|
|
||||||
|
use think\console\command\Make;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\input\Argument;
|
use think\console\input\Argument;
|
||||||
use think\console\input\Option;
|
use think\console\input\Option;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
|
||||||
class Controller extends \think\console\command\Make
|
class Controller extends Make
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
namespace think\console\command\make;
|
namespace think\console\command\make;
|
||||||
|
|
||||||
|
use think\console\command\Make;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\input\Argument;
|
use think\console\input\Argument;
|
||||||
use think\console\input\Option;
|
use think\console\input\Option;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
|
||||||
class File extends \think\console\command\Make
|
class File extends Make
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
namespace think\console\command\make;
|
namespace think\console\command\make;
|
||||||
|
|
||||||
|
use think\console\command\Make;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\input\Argument;
|
use think\console\input\Argument;
|
||||||
use think\console\input\Option;
|
use think\console\input\Option;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
|
||||||
class Model extends \think\console\command\Make
|
class Model extends Make
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class Stream
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造方法
|
* 构造方法
|
||||||
|
* @param $stream
|
||||||
|
* @param Formatter $formatter
|
||||||
*/
|
*/
|
||||||
public function __construct($stream, Formatter $formatter = null)
|
public function __construct($stream, Formatter $formatter = null)
|
||||||
{
|
{
|
||||||
@@ -180,8 +182,12 @@ class Stream
|
|||||||
*/
|
*/
|
||||||
protected function hasColorSupport()
|
protected function hasColorSupport()
|
||||||
{
|
{
|
||||||
if (DIRECTORY_SEPARATOR == '\\') {
|
if (DIRECTORY_SEPARATOR === '\\') {
|
||||||
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
|
return
|
||||||
|
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD)
|
||||||
|
|| false !== getenv('ANSICON')
|
||||||
|
|| 'ON' === getenv('ConEmuANSI')
|
||||||
|
|| 'xterm' === getenv('TERM');
|
||||||
}
|
}
|
||||||
|
|
||||||
return function_exists('posix_isatty') && @posix_isatty($this->stream);
|
return function_exists('posix_isatty') && @posix_isatty($this->stream);
|
||||||
|
|||||||
Reference in New Issue
Block a user