cmd/opts/set.go

40 lines
522 B
Go
Raw Normal View History

2023-11-11 19:28:58 -05:00
package opts
2023-11-10 14:59:37 -05:00
2023-11-11 19:28:58 -05:00
type Set []Option
2023-11-10 14:59:37 -05:00
func NewSet() Set {
return Set{}
}
2023-11-11 19:28:58 -05:00
func (s *Set) Add(f Option) {
*s = append(*s, f)
2023-11-10 14:59:37 -05:00
}
2023-11-11 19:28:58 -05:00
func (s Set) Get(name string) (Option, bool) {
2023-11-10 14:59:37 -05:00
for _, f := range s {
if f.Name() == name {
return f, true
}
if f.ShortName() == name {
return f, true
}
}
return nil, false
}
2023-11-10 15:11:50 -05:00
func (s Set) MaxWidth() int {
max := 0
for _, f := range s {
if w := len(Names(f)); w > max {
max = w
}
}
return max
}
2023-11-10 14:59:37 -05:00
// TODO: Implement
func (s Set) Parse(args []string) error {
return nil
}