private Command TryGetNestedCommand(List <string> extra) { if (NestedCommandSets is null) { return(null); } var nestedCommands = NestedCommandSets.Find(c => c.Suite == extra[0]); if (nestedCommands is null) { return(null); } var extraCopy = new List <string>(extra); extraCopy.RemoveAt(0); if (extraCopy.Count == 0) { return(null); } var command = nestedCommands.GetCommand(extraCopy); if (command != null) { extra.Clear(); extra.AddRange(extraCopy); return(command); } return(null); }
public CommandSet Add(CommandSet nestedCommands) { if (nestedCommands is null) { throw new ArgumentNullException(nameof(nestedCommands)); } if (NestedCommandSets is null) { NestedCommandSets = new List <CommandSet>(); } if (!AlreadyAdded(nestedCommands)) { NestedCommandSets.Add(nestedCommands); foreach (var o in nestedCommands.Options) { if (o is CommandOption c) { Options.Add(new CommandOption(c.Command, $"{nestedCommands.Suite} {c.CommandName}")); } else { Options.Add(o); } } } nestedCommands.Options = Options; nestedCommands.Out = Out; nestedCommands.Error = Error; return(this); }