static int Main(string[] args) { var app = new CommandLineApplication(); app.HelpOption("-?|-h|--help"); var profileArgument = app.Argument("[profile]", "The name of the json profile file to use (excluded file extension)"); app.OnExecute(() => { if (string.IsNullOrEmpty(profileArgument.Value)) { app.ShowHelp(); return(2); } Configure(profileArgument.Value); _messagingServer.Start(); string input; do { Console.WriteLine("Type 'q' to exit."); input = Console.ReadLine(); }while (input != "q"); _messagingServer.Stop(TimeSpan.FromSeconds(10)); return(0); }); int exitCode = app.Execute(args); #if DEBUG Console.WriteLine(); Console.WriteLine("Press any key to continue. . ."); Console.ReadKey(true); #endif return(exitCode); }