2023-11-10 14:59:37 -05:00
|
|
|
package flags
|
|
|
|
|
|
|
|
type Set []Flag
|
|
|
|
|
|
|
|
func NewSet() Set {
|
|
|
|
return Set{}
|
|
|
|
}
|
|
|
|
|
2023-11-11 19:16:05 -05:00
|
|
|
func (s *Set) Add(f Flag) {
|
|
|
|
*s = append(*s, f)
|
2023-11-10 14:59:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s Set) Get(name string) (Flag, bool) {
|
|
|
|
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
|
|
|
|
}
|