From f96058e2f3551ca0834d0499c13bcb02e491be26 Mon Sep 17 00:00:00 2001 From: Markus Keil Date: Mon, 9 Sep 2024 16:34:42 +0200 Subject: [PATCH] improve readabillity --- sherlog-cli/Program.cs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sherlog-cli/Program.cs b/sherlog-cli/Program.cs index de1671e..fb5d6d3 100644 --- a/sherlog-cli/Program.cs +++ b/sherlog-cli/Program.cs @@ -53,20 +53,18 @@ class Program private static string ReadFileIgnoringComments(string filePath) { - StringBuilder contentBuilder = new StringBuilder(); + StringBuilder contentBuilder = new(); try { - using (StreamReader reader = new StreamReader(filePath)) + using StreamReader reader = new(filePath); + string line; + while ((line = reader.ReadLine()) != null) { - string line; - while ((line = reader.ReadLine()) != null) + // Check if the line starts with '#' + if (!line.TrimStart().StartsWith("#")) { - // Check if the line starts with '#' - if (!line.TrimStart().StartsWith("#")) - { - // Process the line as it does not start with '#' - contentBuilder.AppendLine(line); - } + // Process the line as it does not start with '#' + contentBuilder.AppendLine(line); } } } @@ -81,8 +79,7 @@ private static string ReadFileIgnoringComments(string filePath) static async Task Main(string[] args) { string sherlogServer = Environment.GetEnvironmentVariable("SHERLOG_SERVER") ?? "http://localhost:5062"; - Console.WriteLine("==[ Sherlog CLI ]=="); - Console.WriteLine($"Sherlog Server: {sherlogServer}"); + Console.WriteLine("\n\n======[ Sherlog CLI ]======\n"); // look for sherlog config string tenant; @@ -90,7 +87,7 @@ static async Task Main(string[] args) string? sherlogPath = FindSherlogFile(); // Query for tenants - HttpClient hc = new HttpClient(); + HttpClient hc = new(); hc.BaseAddress = new Uri(sherlogServer); List tenants = []; @@ -168,7 +165,7 @@ static async Task Main(string[] args) try { // Start the editor with the temporary file - Process editorProcess = new Process + Process editorProcess = new() { StartInfo = new ProcessStartInfo {