Skip to content

Commit

Permalink
Don't print usage on error
Browse files Browse the repository at this point in the history
  • Loading branch information
punmechanic committed Feb 21, 2024
1 parent c9da0d5 commit 5a72cbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"strings"

"github.com/spf13/cobra"
"golang.org/x/exp/slog"
)

Expand All @@ -28,10 +29,11 @@ func main() {
err := rootCmd.Execute()
var codeErr codeError
if errors.As(err, &codeErr) {
rootCmd.PrintErrf("keyconjurer: %s\n", codeErr.Error())
cobra.CheckErr(codeErr)
os.Exit(int(codeErr.Code()))
} else if err != nil {
rootCmd.PrintErrf("keyconjurer: %s\n", err.Error())
// Probably a cobra error.
cobra.CheckErr(err)
os.Exit(ExitCodeUnknownError)
}
}
1 change: 1 addition & 0 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ To get started run the following commands:
return config.Write(file)
},
SilenceErrors: true,
SilenceUsage: true,
}

0 comments on commit 5a72cbc

Please sign in to comment.