public static void Main(string[] args) { BaseModule?moduleToRun = null; try { ConfiugreStatelessModules(); AppSetting = AppSettingHandler.LoadAppSettings(); string command = SubcommandParser.GetCommand(args, out string[] parameters); DebugHelper.WaitForDebugger(parameters); moduleToRun = GetModuleToRun(command); if (moduleToRun == null) { Console.WriteLine(HelpUtils.GetGeneralHelp()); Exit(ExitCode.UnknownCommand); return; } if (moduleToRun.Execute(parameters) == false) { Console.WriteLine(moduleToRun?.GetHelp()); Exit(ExitCode.BadParameters); } } catch (Exception ex) { HandleUncaughtException(moduleToRun, ex); } }
public static void Main(string[] args) { ModuleBase?moduleToRun = null; try { var loaded = AppSettingHandler.LoadAppSettings(); if (loaded != null) { AppSetting = loaded; } var modulesWithState = CreateModules(); ConfiugreStatelessModules(modulesWithState); string command = SubcommandParser.GetCommand(args, out string[] parameters); DebugHelper.WaitForDebugger(parameters); moduleToRun = GetModuleToRun(StatelessModules, modulesWithState, command); if (moduleToRun == null) { Console.WriteLine(HelpUtils.GetGeneralHelp()); Cleanup(moduleToRun); Exit(ExitCode.UnknownCommand); return; } if (!moduleToRun.Execute(parameters)) { Console.WriteLine(moduleToRun.GetHelp()); Cleanup(moduleToRun); Exit(ExitCode.BadParameters); } Cleanup(moduleToRun); } catch (Exception ex) { #if TESTBUILD if (IsTesting) { ErrorHappened = true; ErrorText = ex.Message; return; } else { #endif HandleUncaughtException(moduleToRun, ex); #if TESTBUILD } #endif } }