From 5850116c0dd49bd42413305e2484beb50cbcc914 Mon Sep 17 00:00:00 2001 From: Sebastien Devaux Date: Mon, 7 Jan 2019 18:56:29 +0100 Subject: [PATCH] Simplified show commadn error handling. Exit on first unknown field found in query. --- commands/show.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/commands/show.go b/commands/show.go index bc89824144d3a8f380d451646250d2314101b619..0b5585f119368092e47b5279d306b054ef74bc3e 100644 --- a/commands/show.go +++ b/commands/show.go @@ -83,8 +83,6 @@ func runShowBug(cmd *cobra.Command, args []string) error { ) } } else { - unknownFields:="" - err:=false for _, field := range showFieldsQuery { switch field { case "author": fmt.Printf("%s ",firstComment.Author.DisplayName()) @@ -98,14 +96,10 @@ func runShowBug(cmd *cobra.Command, args []string) error { case "status": fmt.Printf("%s ",snapshot.Status) case "title": fmt.Printf("%s ",snapshot.Title) default: - unknownFields+=field+" " - err=true + return fmt.Errorf("\nUnsupported field: %s\n",field) } } fmt.Printf("\n") - if err { - return fmt.Errorf("Unsupported fields requested: %s\n",unknownFields) - } } return nil