/// <summary> /// Generates an invocation for the current command. /// </summary> /// <param name="tokens"></param> /// <returns></returns> /// <remarks>Useful in testing your command structure.</remarks> private Action GetAction(params string[] tokens) { var token = tokens.FirstOrDefault(); var subCommand = SubCommands.FirstOrDefault(cmd => cmd.IsIdentifiedBy(token)); if (subCommand == null) { return(GetAction(tokens, token)); } var theRest = tokens.Skip(1).ToArray(); var action = subCommand.GetAction(theRest); return(action ?? GetAction(tokens, token)); }
public Command FindSubCommand(string name) => SubCommands.FirstOrDefault(sc => sc.Name == name.ToLowerInvariant() || sc.Aliases.Contains(name.ToLowerInvariant()));
internal Command GetSubCommandByToken(string token) { return(SubCommands.FirstOrDefault(cmd => cmd.IsIdentifiedBy(token))); }