get rid of interface{} since we now require Go 1.18
This commit is contained in:
@@ -52,7 +52,7 @@ func is_string_slice(f reflect.Value) bool {
|
||||
return f.Type().Elem().Kind() == reflect.String
|
||||
}
|
||||
|
||||
func OptionsFromStruct(pointer_to_options_struct interface{}) ([]*Option, error) {
|
||||
func OptionsFromStruct(pointer_to_options_struct any) ([]*Option, error) {
|
||||
val := reflect.ValueOf(pointer_to_options_struct).Elem()
|
||||
if val.Kind() != reflect.Struct {
|
||||
return nil, fmt.Errorf("Need a pointer to a struct to set option values on")
|
||||
@@ -105,7 +105,7 @@ func option_from_string(overrides map[string]string, entries ...string) (*Option
|
||||
}
|
||||
ans := Option{
|
||||
values_from_cmdline: make([]string, 0, 1),
|
||||
parsed_values_from_cmdline: make([]interface{}, 0, 1),
|
||||
parsed_values_from_cmdline: make([]any, 0, 1),
|
||||
}
|
||||
scanner := utils.NewScanLines(entries...)
|
||||
in_help := false
|
||||
|
||||
@@ -50,8 +50,8 @@ type Option struct {
|
||||
Parent *Command
|
||||
|
||||
values_from_cmdline []string
|
||||
parsed_values_from_cmdline []interface{}
|
||||
parsed_default interface{}
|
||||
parsed_values_from_cmdline []any
|
||||
parsed_default any
|
||||
seen_option string
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func NormalizeOptionName(name string) string {
|
||||
return strings.ReplaceAll(strings.TrimLeft(name, "-"), "_", "-")
|
||||
}
|
||||
|
||||
func (self *Option) parsed_value() interface{} {
|
||||
func (self *Option) parsed_value() any {
|
||||
if len(self.values_from_cmdline) == 0 {
|
||||
return self.parsed_default
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func (self *Option) parsed_value() interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Option) parse_value(val string) (interface{}, error) {
|
||||
func (self *Option) parse_value(val string) (any, error) {
|
||||
switch self.OptionType {
|
||||
case BoolOption:
|
||||
switch val {
|
||||
@@ -455,7 +455,7 @@ type Context struct {
|
||||
SeenCommands []*Command
|
||||
}
|
||||
|
||||
func (self *Command) GetOptionValues(pointer_to_options_struct interface{}) error {
|
||||
func (self *Command) GetOptionValues(pointer_to_options_struct any) error {
|
||||
m := make(map[string]*Option, 128)
|
||||
for _, g := range self.OptionGroups {
|
||||
for _, o := range g.Options {
|
||||
|
||||
Reference in New Issue
Block a user