Commit 51357e58 authored by Carsten Brandt's avatar Carsten Brandt

more console helper and controller refactoring

changed name of ansi switch to --colors
https://github.com/yiisoft/yii2/commit/69cad905dd049be9d9b35d8103cd60591e13c6ae#commitcomment-3168489
issue #33
parent fc5045fd
......@@ -36,10 +36,12 @@ class Controller extends \yii\base\Controller
public $interactive = true;
/**
* @var bool whether to enable ANSI style in output. If not set it will be auto detected.
* Default is disabled on Windows systems and enabled on linux.
* @var bool whether to enable ANSI style in output.
* Setting this will affect [[ansiFormat()]], [[stdout()]] and [[stderr()]].
* If not set it will be auto detected using [[yii\helpers\Console::streamSupportsAnsiColors()]] with STDOUT
* for [[ansiFormat()]] and [[stdout()]] and STDERR for [[stderr()]].
*/
public $ansi;
public $colors;
/**
* Runs an action with the specified action ID and parameters.
......@@ -192,47 +194,6 @@ class Controller extends \yii\base\Controller
return fwrite(STDERR, $string);
}
/**
* Asks the user for input. Ends when the user types a carriage return (PHP_EOL). Optionally, It also provides a
* prompt.
*
* @param string $prompt the prompt (optional)
* @return string the user's input
*/
public function input($prompt = null)
{
if (isset($prompt)) {
$this->stdout($prompt);
}
return Console::stdin();
}
/**
* Prints text to STDOUT appended with a carriage return (PHP_EOL).
*
* @param string $text
* @param bool $raw
*
* @return mixed Number of bytes printed or bool false on error
*/
public function output($text = null)
{
return $this->stdout($text . PHP_EOL);
}
/**
* Prints text to STDERR appended with a carriage return (PHP_EOL).
*
* @param string $text
* @param bool $raw
*
* @return mixed Number of bytes printed or false on error
*/
public function error($text = null)
{
return $this->stderr($text . PHP_EOL);
}
/**
* Prompts the user for input and validates it
*
......@@ -248,7 +209,11 @@ class Controller extends \yii\base\Controller
*/
public function prompt($text, $options = array())
{
return Console::prompt($text, $options);
if ($this->interactive) {
return Console::prompt($text, $options);
} else {
return isset($options['default']) ? $options['default'] : '';
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment