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

@@ -48,6 +48,15 @@ func (self *CommandGroup) FindSubCommand(name string) *Command {
return nil
}
func (self *CommandGroup) FindSubCommands(prefix string, matches []*Command) []*Command {
for _, c := range self.SubCommands {
if strings.HasPrefix(c.Name, prefix) {
matches = append(matches, c)
}
}
return matches
}
type OptionGroup struct {
Options []*Option
Title string