From 063eb45f8b035c3a6f8b2a1cda4b6add63e5f30e Mon Sep 17 00:00:00 2001 From: David Fowler Date: Tue, 20 Oct 2015 02:42:29 -0700 Subject: [PATCH] Moved the reporter to shared code --- src/Microsoft.DotNet.Cli.Utils/Command.cs | 12 ++++++++++-- .../Reporter.cs | 0 src/Microsoft.DotNet.Cli/project.json | 4 ++++ src/Microsoft.DotNet.Tools.Publish/Reporter.cs | 12 ------------ 4 files changed, 14 insertions(+), 14 deletions(-) rename src/{Microsoft.DotNet.Tools.Compiler => Microsoft.DotNet.Cli.Utils}/Reporter.cs (100%) delete mode 100644 src/Microsoft.DotNet.Tools.Publish/Reporter.cs diff --git a/src/Microsoft.DotNet.Cli.Utils/Command.cs b/src/Microsoft.DotNet.Cli.Utils/Command.cs index f7efcfb50..c61e19a6c 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Command.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Command.cs @@ -130,7 +130,7 @@ namespace Microsoft.DotNet.Cli.Utils #if DEBUG var sw = Stopwatch.StartNew(); - Console.WriteLine($"> {_process.StartInfo.FileName} {_process.StartInfo.Arguments}"); + Reporter.Output.WriteLine($"> {_process.StartInfo.FileName} {_process.StartInfo.Arguments}".Green().Bold()); #endif _process.Start(); _process.BeginOutputReadLine(); @@ -139,7 +139,15 @@ namespace Microsoft.DotNet.Cli.Utils var exitCode = await _processTcs.Task; #if DEBUG - Console.WriteLine($"> {_process.StartInfo.FileName} {_process.StartInfo.Arguments} exited with {exitCode} in {sw.ElapsedMilliseconds} ms."); + var message = $"> {_process.StartInfo.FileName} {_process.StartInfo.Arguments} exited with {exitCode} in {sw.ElapsedMilliseconds} ms."; + if (exitCode == 0) + { + Reporter.Output.WriteLine(message.Green().Bold()); + } + else + { + Reporter.Output.WriteLine(message.Red().Bold()); + } #endif return new CommandResult( diff --git a/src/Microsoft.DotNet.Tools.Compiler/Reporter.cs b/src/Microsoft.DotNet.Cli.Utils/Reporter.cs similarity index 100% rename from src/Microsoft.DotNet.Tools.Compiler/Reporter.cs rename to src/Microsoft.DotNet.Cli.Utils/Reporter.cs diff --git a/src/Microsoft.DotNet.Cli/project.json b/src/Microsoft.DotNet.Cli/project.json index 2c8acbb10..01f4516ac 100644 --- a/src/Microsoft.DotNet.Cli/project.json +++ b/src/Microsoft.DotNet.Cli/project.json @@ -17,6 +17,10 @@ "Microsoft.DotNet.Cli.Utils": { "type": "build", "version": "1.0.0-*" + }, + "Microsoft.Extensions.CommandLineUtils.Sources": { + "type": "build", + "version": "1.0.0-*" } }, "frameworks": { diff --git a/src/Microsoft.DotNet.Tools.Publish/Reporter.cs b/src/Microsoft.DotNet.Tools.Publish/Reporter.cs deleted file mode 100644 index f5b5ea57f..000000000 --- a/src/Microsoft.DotNet.Tools.Publish/Reporter.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Runtime.InteropServices; -using Microsoft.Dnx.Runtime.Common.CommandLine; - -namespace Microsoft.DotNet.Cli.Utils -{ - // Stupid-simple console manager - internal static class Reporter - { - public static AnsiConsole Output { get; } = AnsiConsole.GetOutput(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - public static AnsiConsole Error { get; } = AnsiConsole.GetError(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - } -}