add (opt|arg).Repeats()

This commit is contained in:
Roberto Hidalgo 2024-06-20 19:37:10 -06:00
parent 4ffa7ba364
commit 58b225f25e
2 changed files with 10 additions and 0 deletions

View File

@ -182,6 +182,11 @@ func (arg *Argument) SetValue(value []string) {
arg.provided = &value
}
// Repeats tells if an argument should be presented as a list.
func (arg *Argument) Repeats() bool {
return arg.Variadic
}
func (arg *Argument) IsKnown() bool {
return arg.provided != nil && len(*arg.provided) > 0
}

View File

@ -137,6 +137,11 @@ func (opt *Option) ToString() string {
return stringValue
}
// Repeats tells if an option should be presented as a list.
func (opt *Option) Repeats() bool {
return opt.Repeated
}
func (opt *Option) internalValidate(name, current string) error {
if current == "" {
return nil