mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-04 14:46:03 +00:00
Allow using unabiguous long option prefixes
This commit is contained in:
parent
7d5849cc17
commit
74b1cac344
5 changed files with 60 additions and 3 deletions
|
|
@ -347,6 +347,30 @@ func (self *Command) Add(s OptionSpec) *Option {
|
|||
return self.AddToGroup("", s)
|
||||
}
|
||||
|
||||
func (self *Command) FindOptions(name_with_hyphens string) []*Option {
|
||||
ans := make([]*Option, 0, 4)
|
||||
for _, g := range self.OptionGroups {
|
||||
x := g.FindOptions(name_with_hyphens)
|
||||
if x != nil {
|
||||
ans = append(ans, x...)
|
||||
}
|
||||
}
|
||||
depth := 0
|
||||
for p := self.Parent; p != nil; p = p.Parent {
|
||||
depth++
|
||||
x := p.FindOptions(name_with_hyphens)
|
||||
if x != nil {
|
||||
for _, po := range x {
|
||||
if po.Depth >= depth {
|
||||
ans = append(ans, po)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ans
|
||||
|
||||
}
|
||||
|
||||
func (self *Command) FindOption(name_with_hyphens string) *Option {
|
||||
for _, g := range self.OptionGroups {
|
||||
q := g.FindOption(name_with_hyphens)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue