From 298479efbe3b79aeb0303ae20de083cd2b7e783c Mon Sep 17 00:00:00 2001 From: Tom Wright Date: Tue, 9 Nov 2021 16:56:05 +0000 Subject: [PATCH] Clean up error output --- cmd/dasel/main.go | 3 +-- internal/command/root.go | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/dasel/main.go b/cmd/dasel/main.go index be27602..0369d23 100644 --- a/cmd/dasel/main.go +++ b/cmd/dasel/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "github.com/tomwright/dasel/internal/command" "os" ) @@ -10,7 +9,7 @@ func main() { cmd := command.NewRootCMD() command.ChangeDefaultCommand(cmd, "select", "-v", "--version", "help") if err := cmd.Execute(); err != nil { - _, _ = fmt.Fprintln(os.Stderr, "Error: "+err.Error()) + cmd.PrintErrln("Error:", err.Error()) os.Exit(1) } } diff --git a/internal/command/root.go b/internal/command/root.go index f25706d..109b1a3 100644 --- a/internal/command/root.go +++ b/internal/command/root.go @@ -10,8 +10,10 @@ import ( // NewRootCMD returns the root command for use with cobra. func NewRootCMD() *cobra.Command { cmd := &cobra.Command{ - Use: "dasel", - Short: "Query and modify data structures using selector strings.", + Use: "dasel", + Short: "Query and modify data structures using selector strings.", + SilenceErrors: true, + SilenceUsage: true, } cmd.Version = internal.Version cmd.AddCommand(