public void Start(string[] args) { try { var commands = GetCommands(args); var flags = GetFlags(args); _commandMode = commands.Count > 0; var commandIndex = 0; //TODO: This is only used by the voice console. Solve that some other way! //_rootCommand.Initiate(); if (TaskRunners != null) { Task.Run(() => { foreach (var runner in TaskRunners) { runner.Start(); } }, CancellationToken); } if (flags.Any()) { HandleFlags(flags); } while (!_cancellationTokenSource.IsCancellationRequested) { string entry; if (_commandMode) { entry = GetCommandModeEntry(commands, ref commandIndex, flags); } else { try { entry = RootCommand.QueryInput(); } catch (CommandEscapeException) { continue; } } if (!Execute(entry)) { if (_commandMode && HasFlag(args, FlagContinueInConsoleModeIfError)) { _commandMode = false; continue; } break; } } if (TaskRunners != null) { Parallel.ForEach(TaskRunners, x => x.Close()); } } catch (Exception exception) { try { RootCommand.Console.OutputError(exception, true); } catch (Exception e) { System.Console.WriteLine(e.Message + " Original: " + exception.Message + " @" + exception.StackTrace); } } }