Fix color printing and verbosity.

Only apply the ANSI passthrough for child commands. Otherwise the
escape codes are printed to the console on Windows

Make Report.Write process escape codes so that forwarded output will have
its escape codes processed.

Also make verbose be inherited by all child processes.
This commit is contained in:
Austin Wise 2016-02-05 12:55:09 -08:00
parent f273ea4f7d
commit 468a0f38a5
5 changed files with 29 additions and 14 deletions

View file

@ -74,7 +74,7 @@ Common Commands:
{
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
var verbose = false;
bool? verbose = null;
var success = true;
var command = string.Empty;
var lastArg = 0;
@ -114,6 +114,11 @@ Common Commands:
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
if (verbose.HasValue)
{
Environment.SetEnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString());
}
if (string.IsNullOrEmpty(command) || command.Equals("help", StringComparison.OrdinalIgnoreCase))
{
return RunHelpCommand(appArgs);
@ -140,15 +145,10 @@ Common Commands:
Func<string[], int> builtIn;
if (builtIns.TryGetValue(command, out builtIn))
{
// mimic the env variable
Environment.SetEnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString());
Environment.SetEnvironmentVariable(CommandContext.Variables.AnsiPassThru, bool.TrueString);
return builtIn(appArgs.ToArray());
}
return Command.Create("dotnet-" + command, appArgs, FrameworkConstants.CommonFrameworks.DnxCore50)
.EnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString())
.EnvironmentVariable(CommandContext.Variables.AnsiPassThru, bool.TrueString)
.ForwardStdErr()
.ForwardStdOut()
.Execute()