Skip to content

Commit 2214295

Browse files
authored
Do not print red success message (Azure#23210)
Fixes Azure#22347
1 parent 80de9c4 commit 2214295

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

eng/SnippetGenerator/Program.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public async Task OnExecuteAsync()
4141
unUsedSnippets = (await new DirectoryProcessor(BasePath).ProcessAsync()).ToList();
4242
}
4343
Console.WriteLine();
44-
Console.ForegroundColor = ConsoleColor.Red;
4544
string message = $"Not all snippets were used.\n{string.Join(Environment.NewLine, unUsedSnippets)}";
4645
unUsedSnippets.Sort();
4746
if (StrictMode)
@@ -53,31 +52,37 @@ public async Task OnExecuteAsync()
5352
}
5453
else
5554
{
56-
Console.WriteLine(message);
55+
WriteError(message);
5756
}
5857
sw.Stop();
5958
Console.WriteLine($"SnippetGenerator completed in {sw.Elapsed}");
6059
}
6160

6261
public static int Main(string[] args)
6362
{
64-
ConsoleColor foreground = Console.ForegroundColor;
65-
6663
try
6764
{
6865
return CommandLineApplication.Execute<Program>(args);
6966
}
7067
catch (Exception e)
7168
{
72-
Console.ForegroundColor = ConsoleColor.Red;
73-
74-
Console.Error.WriteLine(e.ToString());
69+
WriteError(e.ToString());
7570
return 1;
7671
}
72+
}
73+
74+
private static void WriteError(string message, params object[] args)
75+
{
76+
ConsoleColor foreground = Console.ForegroundColor;
77+
try
78+
{
79+
Console.ForegroundColor = ConsoleColor.Red;
80+
Console.WriteLine(message, args);
81+
}
7782
finally
7883
{
7984
Console.ForegroundColor = foreground;
8085
}
8186
}
8287
}
83-
}
88+
}

0 commit comments

Comments
 (0)