Skip to content

Commit aff9f46

Browse files
committed
go: simplify option parsing with tagged switch
1 parent 67c1d3c commit aff9f46

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

options.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ func parseOptions(args []string) (Command, error) {
272272
case "stats":
273273
opts := statsOptions{}
274274
for _, opt := range args[1:] {
275-
switch {
276-
case opt == "--color":
275+
switch opt {
276+
case "--color":
277277
opts.color = defaultColor()
278-
case opt == "--table":
278+
case "--table":
279279
opts.table = true
280280
default:
281281
return Command{}, fmt.Errorf("unrecognized option: %s", opt)
@@ -356,10 +356,10 @@ func parseOptions(args []string) (Command, error) {
356356
case "version":
357357
opts := versionOptions{}
358358
for _, opt := range args[1:] {
359-
switch {
360-
case opt == "--verbose":
359+
switch opt {
360+
case "--verbose":
361361
opts.verbose = true
362-
case opt == "--check":
362+
case "--check":
363363
opts.check = true
364364
default:
365365
return Command{}, fmt.Errorf("unrecognized option: %s", opt)

0 commit comments

Comments
 (0)