Use System.Console on Unix
This commit is contained in:
parent
2aedd677c6
commit
619eaa0c55
2 changed files with 11 additions and 25 deletions
|
@ -8,28 +8,23 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
{
|
||||
public class AnsiConsole
|
||||
{
|
||||
private AnsiConsole(TextWriter writer, bool useConsoleColor)
|
||||
private AnsiConsole(TextWriter writer)
|
||||
{
|
||||
Writer = writer;
|
||||
|
||||
_useConsoleColor = useConsoleColor;
|
||||
if (_useConsoleColor)
|
||||
{
|
||||
OriginalForegroundColor = Console.ForegroundColor;
|
||||
}
|
||||
OriginalForegroundColor = Console.ForegroundColor;
|
||||
}
|
||||
|
||||
private int _boldRecursion;
|
||||
private bool _useConsoleColor;
|
||||
|
||||
public static AnsiConsole GetOutput(bool useConsoleColor)
|
||||
public static AnsiConsole GetOutput()
|
||||
{
|
||||
return new AnsiConsole(Console.Out, useConsoleColor);
|
||||
return new AnsiConsole(Console.Out);
|
||||
}
|
||||
|
||||
public static AnsiConsole GetError(bool useConsoleColor)
|
||||
public static AnsiConsole GetError()
|
||||
{
|
||||
return new AnsiConsole(Console.Error, useConsoleColor);
|
||||
return new AnsiConsole(Console.Error);
|
||||
}
|
||||
|
||||
public TextWriter Writer { get; }
|
||||
|
@ -61,12 +56,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
public void Write(string message)
|
||||
{
|
||||
if (!_useConsoleColor)
|
||||
{
|
||||
Writer.Write(message);
|
||||
return;
|
||||
}
|
||||
|
||||
var escapeScan = 0;
|
||||
for (;;)
|
||||
{
|
||||
|
|
|
@ -19,14 +19,11 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
_console = console;
|
||||
}
|
||||
|
||||
public static Reporter Output { get; } = Create(AnsiConsole.GetOutput);
|
||||
public static Reporter Error { get; } = Create(AnsiConsole.GetError);
|
||||
public static Reporter Verbose { get; } = CommandContext.IsVerbose() ? Create(AnsiConsole.GetOutput) : NullReporter;
|
||||
|
||||
public static Reporter Create(Func<bool, AnsiConsole> getter)
|
||||
{
|
||||
return new Reporter(getter(PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows));
|
||||
}
|
||||
public static Reporter Output { get; } = new Reporter(AnsiConsole.GetOutput());
|
||||
public static Reporter Error { get; } = new Reporter(AnsiConsole.GetError());
|
||||
public static Reporter Verbose { get; } = CommandContext.IsVerbose() ?
|
||||
new Reporter(AnsiConsole.GetOutput()) :
|
||||
NullReporter;
|
||||
|
||||
public void WriteLine(string message)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue