Allow un-ambiguous prefixes for command names

This commit is contained in:
Kovid Goyal
2022-09-30 15:37:03 +05:30
parent 75ead358a2
commit 0dab006733
3 changed files with 33 additions and 5 deletions

View File

@@ -333,6 +333,18 @@ func (self *Command) FindSubCommand(name string) *Command {
return nil
}
func (self *Command) FindSubCommands(prefix string) []*Command {
c := self.FindSubCommand(prefix)
if c != nil {
return []*Command{c}
}
ans := make([]*Command, 0, 4)
for _, g := range self.SubCommandGroups {
ans = g.FindSubCommands(prefix, ans)
}
return ans
}
func (self *Command) AddOptionGroup(title string) *OptionGroup {
for _, g := range self.OptionGroups {
if g.Title == title {