func (i *item) IsBoolFlag() bool {
	return i.noarg
}
IsBoolFlag implements the hidden interface
documented here https://golang.org/pkg/flag/#Value
package opts
import (
	"encoding"
	"errors"
	"fmt"
	"reflect"
	"time"
)
type itemGroup struct {
	name  string
	flags []*item
}
const defaultGroup = ""
type item struct {
	val       reflect.Value
	mode      string
	name      string
	shortName string
	envName   string
	useEnv    bool
	help      string
	defstr    string
	slice     bool
	min, max  int  
	noarg     bool
	completer Completer
	sets      int
}
func newItem(val reflect.Value) (*item, error) {
	if !val.IsValid() {
		return nil, fmt.Errorf("invalid value")
	}
	i := &item{}
	supported := false
	v := val.Interface()
	pv := interface{}(nil)
	if val.CanAddr() {
		pv = val.Addr().Interface()
	}
	for _, t := range []interface{}{v, pv} {
		if tm, ok := t.(encoding.TextUnmarshaler); ok {
			v = &textValue{tm}
		} else if bm, ok := t.(encoding.BinaryUnmarshaler); ok {
			v = &binaryValue{bm}
		} else if d, ok := t.(*time.Duration); ok {
			v = newDurationValue(d)
		} else if s, ok := t.(Setter); ok {
			v = s
		}
	}
	if s, ok := v.(Setter); ok {
		supported = true
		val = reflect.ValueOf(s)
	}
	if c, ok := v.(Completer); ok {
		i.completer = c
	}
	if val.Kind() == reflect.Ptr {
		val = val.Elem()
	}
	i.val = val
	i.slice = val.Kind() == reflect.Slice
	if i.slice && val.Len() > 0 {
		return nil, fmt.Errorf("slices cannot have default values")
	}
	t := i.elemType()
	if t.Kind() == reflect.Ptr {
		return nil, fmt.Errorf("slice elem (%s) cannot be a pointer", t.Kind())
	} else if i.slice && t.Kind() == reflect.Bool {
		return nil, fmt.Errorf("slice of bools not supported")
	}
	switch t.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
		reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
		reflect.Float32, reflect.Float64,
		reflect.String, reflect.Bool:
		supported = true
	}
	if bf, ok := v.(interface{ IsBoolFlag() bool }); ok {
		i.noarg = bf.IsBoolFlag()
	} else if t.Kind() == reflect.Bool {
		i.noarg = true
	}
	if !supported {
		return nil, fmt.Errorf("field type not supported: %s", t.Kind())
	}
	return i, nil
}
func (i *item) set() bool {
	return i.sets != 0
}
func (i *item) elemType() reflect.Type {
	t := i.val.Type()
	if i.slice {
		t = t.Elem()
	}
	return t
}
func (i *item) String() string {
	if !i.val.IsValid() {
		return ""
	}
	v := i.val.Interface()
	if s, ok := v.(fmt.Stringer); ok {
		return s.String()
	}
	return fmt.Sprintf("%v", v)
}
func (i *item) Set(s string) error {
	if i.sets != 0 && !i.slice {
		return errors.New("already set")
	}
	var elem reflect.Value
	if i.slice {
		elem = reflect.New(i.elemType())  
	} else if i.val.CanAddr() {
		elem = i.val.Addr()  
	} else {
		elem = i.val  
	}
	v := elem.Interface()
	if fv, ok := v.(Setter); ok {
		if err := fv.Set(s); err != nil {
			return err
		}
	} else if elem.Kind() == reflect.Ptr && elem.Elem().Kind() == reflect.String {
		src := reflect.ValueOf(s)
		dst := elem.Elem()
		st := src.Type()
		dt := dst.Type()
		if !st.AssignableTo(dt) {
			if !st.ConvertibleTo(dt) {
				return fmt.Errorf("cannot convert %s to %s", st, dt)
			}
			src = src.Convert(dt)
		}
		dst.Set(src)
	} else if elem.Kind() == reflect.Ptr {
		n, err := fmt.Sscanf(s, "%v", v)
		if err != nil {
			return err
		} else if n == 0 {
			return errors.New("could not be parsed")
		}
	} else {
		return errors.New("could not be set")
	}
	if i.slice {
		if elem.Kind() == reflect.Ptr {
			elem = elem.Elem()
		}
		i.val.Set(reflect.Append(i.val, elem))
	}
	i.sets++
	return nil
}