static void Main(string[] args) { if (args.Length == 0) { PrintUsageHeader(); PrintUsage(); Environment.Exit(-1); } ICommand command = null; switch (args[0]) { case StartElectronCommand.COMMAND_NAME: command = new StartElectronCommand(args.Skip(1).ToArray()); break; case BuildCommand.COMMAND_NAME: command = new BuildCommand(); break; case InitCommand.COMMAND_NAME: command = new InitCommand(); break; case "--help": case "--h": case "help": PrintUsageHeader(); if (args.Length > 1) { PrintUsage(args[1]); } else { PrintUsage(); } break; default: Console.Error.WriteLine($"Unknown command {args[0]}"); PrintUsage(); Environment.Exit(-1); break; } if (command != null) { var success = command.ExecuteAsync().Result; if (!success) { Environment.Exit(-1); } } }
/// <summary> /// Initialize view model. /// </summary> /// <param name="parameter">initialization parameter</param> /// <returns></returns> public async Task Initiate(TParameter parameter) { var task = typeof(TParameter) != typeof(object) ? InitCommand.ExecuteAsync(parameter) : InitCommand.ExecuteAsync(); await task; }