Skip to content

Commit

Permalink
refactor: cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Dec 1, 2020
1 parent 6d7b776 commit 11d59a2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@ func checkAndConvertOptions(root *Command, opts OptMap, path []string) (OptMap,
k, opt.Type().String(), kind.String())
}
} else {
if str, ok := v.(string); ok {
val, err := opt.Parse(str)
if err != nil {
value := fmt.Sprintf("value %q", v)
if len(str) == 0 {
value = "empty value"
}
return options, fmt.Errorf("could not convert %s to type %q (for option %q)",
value, opt.Type().String(), "-"+k)
}
options[k] = val

} else {
str, ok := v.(string)
if !ok {
return options, fmt.Errorf("option %q should be type %q, but got type %q",
k, opt.Type().String(), kind.String())
}

val, err := opt.Parse(str)
if err != nil {
value := fmt.Sprintf("value %q", v)
if len(str) == 0 {
value = "empty value"
}
return options, fmt.Errorf("could not convert %s to type %q (for option %q)",
value, opt.Type().String(), "-"+k)
}
options[k] = val
}
}

Expand Down

0 comments on commit 11d59a2

Please sign in to comment.