From 2c221f39a8d01784a04f8f334ed560f4fe6a915a Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 4 Oct 2018 19:07:08 +0200 Subject: [PATCH 1/2] Write error message to STDERR --- dotnet-sourcelink/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-sourcelink/Program.cs b/dotnet-sourcelink/Program.cs index e0d32e6..4928b1b 100644 --- a/dotnet-sourcelink/Program.cs +++ b/dotnet-sourcelink/Program.cs @@ -46,7 +46,7 @@ public static int Main(string[] args) } catch (Exception ex) { - Console.WriteLine(ex.Message); + Console.Error.WriteLine(ex.Message); return -1; } } From 7e57beddd85efc50baf72089fc35a6f8976b17b3 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 4 Oct 2018 19:18:26 +0200 Subject: [PATCH 2/2] More error messages that belong on STDERR --- dotnet-sourcelink/Program.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dotnet-sourcelink/Program.cs b/dotnet-sourcelink/Program.cs index 4928b1b..8fcbf23 100644 --- a/dotnet-sourcelink/Program.cs +++ b/dotnet-sourcelink/Program.cs @@ -67,20 +67,20 @@ public static void PrintJson(CommandLineApplication command) } if (!File.Exists(path)) { - Console.WriteLine("file does not exist: " + path); + Console.Error.WriteLine("file does not exist: " + path); return 3; } using (var drp = DebugReaderProvider.Create(path)) { if(drp == null) { - Console.WriteLine("unable to read debug info: " + path); + Console.Error.WriteLine("unable to read debug info: " + path); return 5; } var bytes = GetSourceLinkBytes(drp); if (bytes == null || bytes.Length == 0) { - Console.WriteLine("Source Link JSON not found in file: " + path); + Console.Error.WriteLine("Source Link JSON not found in file: " + path); return 4; } Console.WriteLine(Encoding.UTF8.GetString(bytes)); @@ -106,7 +106,7 @@ public static void PrintDocuments(CommandLineApplication command) } if (!File.Exists(path)) { - Console.WriteLine("file does not exist: " + path); + Console.Error.WriteLine("file does not exist: " + path); return 3; } @@ -114,7 +114,7 @@ public static void PrintDocuments(CommandLineApplication command) { if (drp == null) { - Console.WriteLine("unable to read debug info: " + path); + Console.Error.WriteLine("unable to read debug info: " + path); return 4; } foreach (var doc in GetDocuments(drp)) @@ -143,7 +143,7 @@ public static void PrintUrls(CommandLineApplication command) } if (!File.Exists(path)) { - Console.WriteLine("file does not exist: " + path); + Console.Error.WriteLine("file does not exist: " + path); return 3; } @@ -151,7 +151,7 @@ public static void PrintUrls(CommandLineApplication command) { if (drp == null) { - Console.WriteLine("unable to read debug info: " + path); + Console.Error.WriteLine("unable to read debug info: " + path); return 5; } var missingDocs = new List(); @@ -174,10 +174,10 @@ public static void PrintUrls(CommandLineApplication command) } if (missingDocs.Count > 0) { - Console.WriteLine("" + missingDocs.Count + " Documents without URLs:"); + Console.Error.WriteLine("" + missingDocs.Count + " Documents without URLs:"); foreach (var doc in missingDocs) { - Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name); + Console.Error.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name); } return 4; } @@ -193,7 +193,7 @@ public static int TestFile(string path, IAuthenticationHeaderValueProvider authe { if (drp == null) { - Console.WriteLine("unable to read debug info: " + path); + Console.Error.WriteLine("unable to read debug info: " + path); return 5; } return TestFile(drp, authenticationHeaderValueProvider); @@ -308,7 +308,7 @@ public static int TestNupkg(string path, List files, IAuthenticationHead { if (drp == null) { - Console.WriteLine("unable to read debug info: " + path); + Console.Error.WriteLine("unable to read debug info: " + path); return 5; } if (TestFile(drp, authenticationHeaderValueProvider) != 0) @@ -351,7 +351,7 @@ public static void Test(CommandLineApplication command) } if (!File.Exists(path)) { - Console.WriteLine("file does not exist: " + path); + Console.Error.WriteLine("file does not exist: " + path); return 3; }