|
|
@ -14,18 +14,20 @@ namespace System.CommandLine |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
if (_isConsoleRedirectionCheckSupported == null) |
|
|
if (_isConsoleRedirectionCheckSupported != null) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
return _isConsoleRedirectionCheckSupported.Value; |
|
|
{ |
|
|
} |
|
|
var check = Console.IsOutputRedirected; |
|
|
|
|
|
_isConsoleRedirectionCheckSupported = true; |
|
|
try |
|
|
} |
|
|
{ |
|
|
|
|
|
var check = Console.IsOutputRedirected; |
|
|
|
|
|
_isConsoleRedirectionCheckSupported = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
catch (PlatformNotSupportedException) |
|
|
catch (PlatformNotSupportedException) |
|
|
{ |
|
|
{ |
|
|
_isConsoleRedirectionCheckSupported = false; |
|
|
_isConsoleRedirectionCheckSupported = false; |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return _isConsoleRedirectionCheckSupported.Value; |
|
|
return _isConsoleRedirectionCheckSupported.Value; |
|
|
@ -39,12 +41,7 @@ namespace System.CommandLine |
|
|
((dynamic)console).ForegroundColor = color; |
|
|
((dynamic)console).ForegroundColor = color; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (IsConsoleRedirectionCheckSupported && |
|
|
if (IsConsoleRedirectionCheckSupported) |
|
|
!Console.IsOutputRedirected) |
|
|
|
|
|
{ |
|
|
|
|
|
Console.ForegroundColor = color; |
|
|
|
|
|
} |
|
|
|
|
|
else if (IsConsoleRedirectionCheckSupported) |
|
|
|
|
|
{ |
|
|
{ |
|
|
Console.ForegroundColor = color; |
|
|
Console.ForegroundColor = color; |
|
|
} |
|
|
} |
|
|
@ -57,12 +54,7 @@ namespace System.CommandLine |
|
|
((dynamic)console).ForegroundColor = ConsoleColor.Red; |
|
|
((dynamic)console).ForegroundColor = ConsoleColor.Red; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (IsConsoleRedirectionCheckSupported && |
|
|
if (IsConsoleRedirectionCheckSupported) |
|
|
!Console.IsOutputRedirected) |
|
|
|
|
|
{ |
|
|
|
|
|
Console.ResetColor(); |
|
|
|
|
|
} |
|
|
|
|
|
else if (IsConsoleRedirectionCheckSupported) |
|
|
|
|
|
{ |
|
|
{ |
|
|
Console.ResetColor(); |
|
|
Console.ResetColor(); |
|
|
} |
|
|
} |
|
|
|