Line data Source code
1 0 : namespace CalculatorApp { 2 : 3 : /// <summary> 4 : /// Console entry point. All parsing and calculation logic lives in 5 : /// <see cref="CalculatorLibrary.CalculatorCli"/> so it is unit tested there; this class only wires 6 : /// the process arguments to that logic and prints the result. It never calls 7 : /// <c>Console.ReadLine</c> or otherwise waits on keyboard input, so it never blocks when launched 8 : /// from a build script or CI. 9 : /// </summary> 10 : internal class Program { 11 0 : private static int Main(string[] args) { 12 : try { 13 : string output = args.Length == 0 ? CalculatorLibrary.CalculatorCli.RunDemo() : CalculatorLibrary.CalculatorCli.Run(args); 14 : Console.WriteLine(output); 15 : return 0; 16 : } catch (Exception ex) when (ex is ArgumentException or DivideByZeroException) { 17 : Console.Error.WriteLine($"Error: {ex.Message}"); 18 : return 1; 19 : } 20 : } 21 : } 22 : }