/// <summary> /// The main entry point for the application. /// </summary> static int Main() { #if Windows //Console.WriteLine("Windows!"); #endif EAppExitCode exitCode = EAppExitCode.OK; try { log.Debug($"Started with cmdLine: {Environment.CommandLine}"); var ac = new AppConfig(); if (ac.HadErrors) { log.Error("Error parsing command line arguments.\n" + ac.GetUsageHelpText()); exitCode = EAppExitCode.CmdLineError; } else { IApp?app = null; switch (ac.Mode.ToLower()) { default: case "cli": { app = new CliApp(ac, interactive: false); break; } case "telnet": { app = new CliApp(ac, interactive: true); break; } } if (app != null) { exitCode = app.run(); app.Dispose(); } log.Debug($"Exiting gracefully with exitCode {(int)exitCode} ({exitCode})."); } } catch (Exception ex) { log.Error("Exception", ex); exitCode = EAppExitCode.ExceptionError; } return(( int )exitCode); }
/// <summary> /// The main entry point for the application. /// </summary> static int Main() { #if Windows //Console.WriteLine("Windows!"); #endif EAppExitCode exitCode = EAppExitCode.OK; try { log.Info($"Started with cmdLine: {Environment.CommandLine}"); var ac = new AppConfig(); if (ac.HadErrors) { log.Error("Error parsing command line arguments.\n" + ac.GetUsageHelpText()); exitCode = EAppExitCode.CmdLineError; } else { IApp?app = null; switch (ac.Mode.ToLower()) { //case "gui": // just gui, no agent //{ // app = new AgentMasterApp( ac, isAgent: false, isMaster: Tools.BoolFromString( ac.IsMaster ), runGui:true ); // break; //} //// agent + gui //case "traygui": // for compatibility with Dirigent 1.x //case "trayapp": // for compatibility with Dirigent 1.x //case "trayagentgui": //{ // app = new AgentMasterApp( ac, isAgent: true, isMaster: Tools.BoolFromString( ac.IsMaster ), runGui:true ); // break; //} // just agent (no gui) case "": case "daemon": case "agent": { app = new AgentMasterApp(ac, isAgent: true, isMaster: Tools.BoolFromString(ac.IsMaster)); break; } // master only case "master": { app = new AgentMasterApp(ac, isAgent: false, isMaster: true); break; } //case "cli": //{ // app = new CliApp( ac, interactive: false ); // break; //} //case "telnet": //{ // app = new CliApp( ac, interactive: true ); // break; //} default: { log.Error($"Invalid app mode '{ac.Mode}'"); break; } } if (app != null) { exitCode = app.run(); app.Dispose(); } log.Debug($"Exiting gracefully with exitCode {(int)exitCode} ({exitCode})."); } } catch (Exception ex) { log.Error("Exception", ex); exitCode = EAppExitCode.ExceptionError; } return(( int )exitCode); }