Skip to content

Commit 11d59a2

Browse files
committed
refactor: cleanup code
1 parent 6d7b776 commit 11d59a2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

request.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ func checkAndConvertOptions(root *Command, opts OptMap, path []string) (OptMap,
124124
k, opt.Type().String(), kind.String())
125125
}
126126
} else {
127-
if str, ok := v.(string); ok {
128-
val, err := opt.Parse(str)
129-
if err != nil {
130-
value := fmt.Sprintf("value %q", v)
131-
if len(str) == 0 {
132-
value = "empty value"
133-
}
134-
return options, fmt.Errorf("could not convert %s to type %q (for option %q)",
135-
value, opt.Type().String(), "-"+k)
136-
}
137-
options[k] = val
138-
139-
} else {
127+
str, ok := v.(string)
128+
if !ok {
140129
return options, fmt.Errorf("option %q should be type %q, but got type %q",
141130
k, opt.Type().String(), kind.String())
142131
}
132+
133+
val, err := opt.Parse(str)
134+
if err != nil {
135+
value := fmt.Sprintf("value %q", v)
136+
if len(str) == 0 {
137+
value = "empty value"
138+
}
139+
return options, fmt.Errorf("could not convert %s to type %q (for option %q)",
140+
value, opt.Type().String(), "-"+k)
141+
}
142+
options[k] = val
143143
}
144144
}
145145

0 commit comments

Comments
 (0)