Skip to content

Commit

Permalink
[options] Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Jan 16, 2024
1 parent de88c80 commit 017852d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,13 @@ func initOptions(opts *Options) {
}

func parseName(name string) optionName {
na := strings.Split(name, ":")
short, long, ok := strings.Cut(name, ":")

if len(na) == 1 {
return optionName{na[0], ""}
if !ok {
return optionName{short, ""}
}

return optionName{na[1], na[0]}
return optionName{long, short}
}

func parseOptionsList(list string) []optionName {
Expand Down Expand Up @@ -760,7 +760,7 @@ func updateOption(opt *V, name, value string) error {
return updateIntOption(name, opt, value)
}

return fmt.Errorf("Option --%s has unsupported type", parseName(name).Long)
return fmt.Errorf("Option %s has unsupported type", Format(name))
}

func updateStringOption(opt *V, value string) error {
Expand Down

0 comments on commit 017852d

Please sign in to comment.