You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
554 B

package value
import (
"strconv"
"gitoa.ru/go-4devs/console/input"
)
type Bool struct {
Empty
Val []bool
Flag input.Flag
}
func (b *Bool) Append(in string) error {
v, err := strconv.ParseBool(in)
if err != nil {
return err
}
b.Val = append(b.Val, v)
return nil
}
func (b *Bool) Bool() bool {
if !b.Flag.IsArray() && len(b.Val) == 1 {
return b.Val[0]
}
return false
}
func (b *Bool) Bools() []bool {
return b.Val
}
func (b *Bool) Any() interface{} {
if b.Flag&input.ValueArray > 0 {
return b.Bools()
}
return b.Bool()
}