Skip to content

Commit

Permalink
Do not print red success message (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
heaths authored Aug 31, 2021
1 parent 2828d14 commit d5145fc
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public async Task OnExecuteAsync()
unUsedSnippets = (await new DirectoryProcessor(BasePath).ProcessAsync()).ToList();
}
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red;
string message = $"Not all snippets were used.\n{string.Join(Environment.NewLine, unUsedSnippets)}";
unUsedSnippets.Sort();
if (StrictMode)
Expand All @@ -53,27 +52,33 @@ public async Task OnExecuteAsync()
}
else
{
Console.WriteLine(message);
WriteError(message);
}
sw.Stop();
Console.WriteLine($"SnippetGenerator completed in {sw.Elapsed}");
}

public static int Main(string[] args)
{
ConsoleColor foreground = Console.ForegroundColor;

try
{
return CommandLineApplication.Execute<Program>(args);
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;

Console.Error.WriteLine(e.ToString());
WriteError(e.ToString());
return 1;
}
}

private static void WriteError(string message, params object[] args)
{
ConsoleColor foreground = Console.ForegroundColor;
try
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message, args);
}
finally
{
Console.ForegroundColor = foreground;
Expand Down

0 comments on commit d5145fc

Please sign in to comment.