diff --git a/LyricsScraperNET.Client/ConsoleExtensions.cs b/LyricsScraperNET.Client/ConsoleExtensions.cs new file mode 100644 index 0000000..9e04889 --- /dev/null +++ b/LyricsScraperNET.Client/ConsoleExtensions.cs @@ -0,0 +1,27 @@ +using System; + +namespace LyricsScraperNET +{ + public static class ConsoleExtensions + { + private static readonly char indentSymbol = '-'; + + public static void WriteLineColored(this string str, ConsoleColor color = ConsoleColor.Gray, bool reset = true) + { + Console.ForegroundColor = color; + Console.WriteLine(str); + if (reset) + Console.ResetColor(); + } + + public static void WriteLineDelimeter(int repeatAmount = 20, ConsoleColor color = ConsoleColor.Gray, bool reset = true) + { + Console.ForegroundColor = color; + Console.WriteLine(); + Console.WriteLine(new String(indentSymbol, repeatAmount)); + Console.WriteLine(); + if (reset) + Console.ResetColor(); + } + } +} diff --git a/LyricsScraperNET.Client/Program.cs b/LyricsScraperNET.Client/Program.cs index cc64b01..f75c92d 100644 --- a/LyricsScraperNET.Client/Program.cs +++ b/LyricsScraperNET.Client/Program.cs @@ -37,36 +37,40 @@ static async Task Main() //// 2) The requested song contains only the instrumental, no lyrics. In this case the flag 'Instrumental' will be true. if (result.IsEmpty()) { + ConsoleExtensions.WriteLineDelimeter(); if (result.Instrumental) { - Console.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine($"This song [{artistToSearch} - {songToSearch}] is instrumental.\r\nIt does not contain any lyrics"); + $"This song [{artistToSearch} - {songToSearch}] is instrumental.\r\nIt does not contain any lyrics" + .WriteLineColored(ConsoleColor.Gray); } else { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"Can't find lyrics for: [{artistToSearch} - {songToSearch}]. " + + ($"Can't find lyrics for: [{artistToSearch} - {songToSearch}]. " + $"Status code: [{result.ResponseStatusCode}]. " + - $"Response message: [{result.ResponseMessage}]."); + $"Response message: [{result.ResponseMessage}].").WriteLineColored(ConsoleColor.Red); } - Console.ResetColor(); + ConsoleExtensions.WriteLineDelimeter(); + "Press any key to exit..".WriteLineColored(ConsoleColor.DarkGray); Console.ReadLine(); return; } //// Output result to console - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine($"[{artistToSearch} - {songToSearch}]\r\n"); - Console.ResetColor(); + //// Artist and song information + $"[{artistToSearch} - {songToSearch}]".WriteLineColored(ConsoleColor.Yellow); - Console.WriteLine(result.LyricText); + ConsoleExtensions.WriteLineDelimeter(); + //// Lyric text + result.LyricText.WriteLineColored(); + ConsoleExtensions.WriteLineDelimeter(); - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine($"\r\nThis lyric was found by [{result.ExternalProviderType}]\r\n"); - Console.ResetColor(); + //// Lyrics provider information + $"This lyric was found by [{result.ExternalProviderType}]\r\n".WriteLineColored(ConsoleColor.Magenta); + "Press any key to exit..".WriteLineColored(ConsoleColor.DarkGray); Console.ReadLine(); + return; } ///