mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-16 12:35:04 +02:00
Issue 37. Disable color output.
This commit is contained in:
parent
5c51f593d0
commit
e9045cc55e
|
@ -50,6 +50,12 @@ class Console
|
|||
*/
|
||||
private static $commandsOutput = '';
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
* @var Mage/Config
|
||||
*/
|
||||
private static $config;
|
||||
|
||||
/**
|
||||
* Runns a Magallanes Command
|
||||
* @throws Exception
|
||||
|
@ -70,7 +76,7 @@ class Console
|
|||
$configError = false;
|
||||
try {
|
||||
// Load Config
|
||||
$config = new Config;
|
||||
$config = self::$config = new Config;
|
||||
$config->load($arguments);
|
||||
$configLoadedOk = true;
|
||||
|
||||
|
@ -143,7 +149,7 @@ class Console
|
|||
. str_repeat(PHP_EOL, $newLine);
|
||||
|
||||
$output = str_repeat("\t", $tabs)
|
||||
. Console\Colors::color($message)
|
||||
. Console\Colors::color($message, self::$config)
|
||||
. str_repeat(PHP_EOL, $newLine);
|
||||
|
||||
echo $output;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace Mage\Console;
|
||||
|
||||
use Mage\Config;
|
||||
|
||||
/**
|
||||
* Parses the different colors available for the Terminal or Console.
|
||||
*
|
||||
|
@ -47,8 +49,15 @@ class Colors
|
|||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
public static function color($string)
|
||||
public static function color($string, Config $config)
|
||||
{
|
||||
$disabled = $config->getParameter('no-color', !$config->general('colors', true));
|
||||
|
||||
if ($disabled) {
|
||||
$string = strip_tags($string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
foreach (self::$foregroundColors as $key => $code) {
|
||||
$replaceFrom = array(
|
||||
'<' . $key . '>',
|
||||
|
|
Loading…
Reference in a new issue