2022-11-10 11:07:53 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
)
|
|
|
|
|
|
|
|
type boolFlag interface {
|
|
|
|
pflag.Value
|
2023-09-18 23:52:36 +00:00
|
|
|
IsExplicitlySet() bool
|
2022-11-10 11:07:53 +00:00
|
|
|
IsSet() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type unwrapScalarFlagStrc struct {
|
2023-09-18 23:52:36 +00:00
|
|
|
explicitlySet bool
|
|
|
|
value bool
|
2022-11-10 11:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newUnwrapFlag() boolFlag {
|
|
|
|
return &unwrapScalarFlagStrc{value: true}
|
|
|
|
}
|
|
|
|
|
2023-09-18 23:52:36 +00:00
|
|
|
func (f *unwrapScalarFlagStrc) IsExplicitlySet() bool {
|
|
|
|
return f.explicitlySet
|
2022-11-10 11:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *unwrapScalarFlagStrc) IsSet() bool {
|
|
|
|
return f.value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *unwrapScalarFlagStrc) String() string {
|
|
|
|
return strconv.FormatBool(f.value)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *unwrapScalarFlagStrc) Set(value string) error {
|
|
|
|
|
|
|
|
v, err := strconv.ParseBool(value)
|
|
|
|
f.value = v
|
2023-09-18 23:52:36 +00:00
|
|
|
f.explicitlySet = true
|
2022-11-10 11:07:53 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*unwrapScalarFlagStrc) Type() string {
|
|
|
|
return "bool"
|
|
|
|
}
|