update patch 1
This commit is contained in:
+8
-8
@@ -51,7 +51,7 @@ enum AnsiColorMode
|
||||
}
|
||||
|
||||
if (6 !== \strlen($hexColor)) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid "#%s" color.', $hexColor));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid "#%s" color.', $hexColor));
|
||||
}
|
||||
|
||||
$color = hexdec($hexColor);
|
||||
@@ -62,8 +62,8 @@ enum AnsiColorMode
|
||||
|
||||
return match ($this) {
|
||||
self::Ansi4 => (string) $this->convertFromRGB($r, $g, $b),
|
||||
self::Ansi8 => '8;5;'.((string) $this->convertFromRGB($r, $g, $b)),
|
||||
self::Ansi24 => sprintf('8;2;%d;%d;%d', $r, $g, $b),
|
||||
self::Ansi8 => '8;5;'.$this->convertFromRGB($r, $g, $b),
|
||||
self::Ansi24 => \sprintf('8;2;%d;%d;%d', $r, $g, $b),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,11 +96,11 @@ enum AnsiColorMode
|
||||
}
|
||||
|
||||
return (int) round(($r - 8) / 247 * 24) + 232;
|
||||
} else {
|
||||
return 16 +
|
||||
(36 * (int) round($r / 255 * 5)) +
|
||||
(6 * (int) round($g / 255 * 5)) +
|
||||
(int) round($b / 255 * 5);
|
||||
}
|
||||
|
||||
return 16 +
|
||||
(36 * (int) round($r / 255 * 5)) +
|
||||
(6 * (int) round($g / 255 * 5)) +
|
||||
(int) round($b / 255 * 5);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
|
||||
if ($numberOfLinesToClear > 0) {
|
||||
// move cursor up n lines
|
||||
parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
|
||||
parent::doWrite(\sprintf("\x1b[%dA", $numberOfLinesToClear), false);
|
||||
// erase to end of screen
|
||||
parent::doWrite("\x1b[0J", false);
|
||||
}
|
||||
|
||||
+7
-2
@@ -54,12 +54,17 @@ class NullOutput implements OutputInterface
|
||||
|
||||
public function getVerbosity(): int
|
||||
{
|
||||
return self::VERBOSITY_QUIET;
|
||||
return self::VERBOSITY_SILENT;
|
||||
}
|
||||
|
||||
public function isSilent(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isQuiet(): bool
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isVerbose(): bool
|
||||
|
||||
+8
-2
@@ -17,13 +17,14 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
/**
|
||||
* Base class for output classes.
|
||||
*
|
||||
* There are five levels of verbosity:
|
||||
* There are six levels of verbosity:
|
||||
*
|
||||
* * normal: no option passed (normal output)
|
||||
* * verbose: -v (more output)
|
||||
* * very verbose: -vv (highly extended output)
|
||||
* * debug: -vvv (all debug output)
|
||||
* * quiet: -q (no output)
|
||||
* * quiet: -q (only output errors)
|
||||
* * silent: --silent (no output)
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
@@ -74,6 +75,11 @@ abstract class Output implements OutputInterface
|
||||
return $this->verbosity;
|
||||
}
|
||||
|
||||
public function isSilent(): bool
|
||||
{
|
||||
return self::VERBOSITY_SILENT === $this->verbosity;
|
||||
}
|
||||
|
||||
public function isQuiet(): bool
|
||||
{
|
||||
return self::VERBOSITY_QUIET === $this->verbosity;
|
||||
|
||||
@@ -17,9 +17,12 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
* OutputInterface is the interface implemented by all Output classes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @method bool isSilent()
|
||||
*/
|
||||
interface OutputInterface
|
||||
{
|
||||
public const VERBOSITY_SILENT = 8;
|
||||
public const VERBOSITY_QUIET = 16;
|
||||
public const VERBOSITY_NORMAL = 32;
|
||||
public const VERBOSITY_VERBOSE = 64;
|
||||
|
||||
@@ -94,6 +94,11 @@ class StreamOutput extends Output
|
||||
return false;
|
||||
}
|
||||
|
||||
// Follow https://force-color.org/
|
||||
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Detect msysgit/mingw and assume this is a tty because detection
|
||||
// does not work correctly, see https://github.com/composer/composer/issues/9690
|
||||
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ class TrimmedBufferOutput extends Output
|
||||
public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
if ($maxLength <= 0) {
|
||||
throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
|
||||
throw new InvalidArgumentException(\sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
|
||||
}
|
||||
|
||||
parent::__construct($verbosity, $decorated, $formatter);
|
||||
@@ -53,6 +53,6 @@ class TrimmedBufferOutput extends Output
|
||||
$this->buffer .= \PHP_EOL;
|
||||
}
|
||||
|
||||
$this->buffer = substr($this->buffer, 0 - $this->maxLength);
|
||||
$this->buffer = substr($this->buffer, -$this->maxLength);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user