async Task ICommandExecutorImpl.ExecuteInternalAsync(VerbAttribute verb, IEnumerator <CommandPart> commandParts, GlobalOptionsWrapper globalOptions) { if (!commandParts.MoveNext()) { throw new BadCommandException(verb, "Malformed command"); } if (commandParts.Current.IsArgument) { var key = _parser.GetString(commandParts.Current.Key); if (_impl.TrySetGlobalOption(key, commandParts.Current, globalOptions)) { await _impl.ExecuteInternalAsync(verb, commandParts, globalOptions); return; } if (_commandHelper.TryShowHelpOrVersion(commandParts.Current, verb, key, _options, globalOptions)) { return; } throw new BadCommandException(verb, "Unexpected option"); } var name = _parser.GetString(commandParts.Current.Key); if (verb.Verbs.TryGetValue(name, out var nextVerb)) { await _impl.ExecuteInternalAsync(nextVerb, commandParts, globalOptions); return; } if (verb.Commands.TryGetValue(name, out var nextCommand)) { await _impl.ExecuteCommandAsync(nextCommand, commandParts, globalOptions); return; } throw new BadCommandException(verb, name); }