private static int Run(string[] args) { Log4Net.Setup(Constants.Node, args, logToConsole: true); return(Parser.Default.ParseArguments <CommandLineOptions>(args) .MapResult( (CommandLineOptions options) => Application.Run(options), errs => (int)ExitCode.InvalidArgument)); }
private static int Run(string[] args) { Log4Net.Setup(Constants.Distributor, args); try { var result = Parser.Default.ParseArguments <DeployOptions, RunOptions, ListOptions, ExampleOptions>(args); return(result.MapResult( (DeployOptions options) => (int)Deploy(options), (RunOptions options) => (int)Run(options), (ListOptions options) => (int)Run(options), (ExampleOptions options) => ShowExample(options), errs => (int)ExitCode.InvalidArguments)); } catch (ScriptCannotBeAccessedException e) { Console.WriteLine(); Console.WriteLine("Error: {0}", e.Message); return((int)ExitCode.ScriptCannotBeAccessed); } catch (ScriptCompilationException e) { Console.WriteLine(); Console.WriteLine("Build failed:"); foreach (var err in e.Errors) { Console.WriteLine("{0}, {1}", e.ScriptPath, err); } foreach (var warning in e.Warnings) { Console.WriteLine("{0}, {1}", e.ScriptPath, warning); } return((int)ExitCode.CompileError); } catch (ScriptExecutionException e) { Console.WriteLine(); PrintUnhandledScriptException(false, e); return((int)ExitCode.ExecutionError); } catch (NotConnectedException) { Console.WriteLine(); Console.WriteLine("Terminating the application because a node could not be connected to"); return((int)ExitCode.ConnectionError); } catch (Exception e) { Console.WriteLine(); PrintUnhandledException(e); return((int)ExitCode.UnhandledException); } }