public void RunCli() { Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Welcome to Arithmetic Calculator!"); Console.WriteLine("Press ^C or type 'exit' to quit\n"); Console.ForegroundColor = ConsoleColor.White; while (true) { Console.Write("> "); var input = Console.ReadLine(); if (string.IsNullOrWhiteSpace(input)) { continue; } if (input == ExitCommand) { return; } try { var result = _calculator.Calculate(input); Console.WriteLine($"= {result}", ConsoleColor.Green); } catch (AggregateException ex) { foreach (var innerEx in ex.InnerExceptions) { WriteException(innerEx); } } catch (Exception ex) { WriteException(ex); } } }
private static void WriteError(LogSeverity severity, string format, params object[] args) { Console.WriteLine($"[{severity.ToString().ToUpper()}] {format}", ConsoleColor.Red, args); }