static void Main(string[] args) { string credentialsPath = args[0]; string tokenDir = args[1]; if (!File.Exists(credentialsPath) || !Directory.Exists(tokenDir)) { throw new ArgumentException("Must pass in credentials file location and token directory"); } _log = new ConsoleTraceLogger("Gman.UI.Iron"); var factory = new GmailServiceFactory(); _service = factory.BuildAsync(new GmailServiceConfig { ApiScopes = new[] { GmailService.Scope.GmailReadonly, GmailService.Scope.GmailSend }, AppName = "Mekmak Gman", CredentialsFilePath = credentialsPath, TokenDirectory = tokenDir }).Result; _messageProvider = new MessageProvider(_log.GetSubLogger("MessageProvider"), _service); while (true) { Console.Write("> "); var command = ConsoleCommand.New(Console.ReadLine()); if (command.Current == "quit" || command.Current == "exit") { Console.WriteLine("Goodbye!"); return; } try { ProcessCommand(command); } catch (Exception ex) { Console.WriteLine(); ConsoleWriter.WriteInRed($"ERROR: {ex.Message}"); ConsoleWriter.WriteInRed($"{ex.StackTrace}"); Console.WriteLine(); } } }