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.

45 lines
562 B

4 years ago
package value
import (
"strconv"
4 years ago
"gitoa.ru/go-4devs/console/input/flag"
4 years ago
)
type Int64 struct {
empty
4 years ago
Val []int64
4 years ago
Flag flag.Flag
4 years ago
}
func (i *Int64) Int64() int64 {
if !i.Flag.IsArray() && len(i.Val) == 1 {
return i.Val[0]
}
return 0
}
func (i *Int64) Int64s() []int64 {
return i.Val
}
func (i *Int64) Any() interface{} {
4 years ago
if i.Flag.IsArray() {
4 years ago
return i.Int64s()
}
return i.Int64()
}
func (i *Int64) Append(in string) error {
v, err := strconv.ParseInt(in, 10, 64)
if err != nil {
return err
}
i.Val = append(i.Val, v)
return nil
}