Merge pull request #337 from Icinga/bugfix/icingadb-help-should-not-display-a-stack-trace-at-the-end-334

Don't print stack on CLI parsing failure or --help
This commit is contained in:
Alexander Aleksandrovič Klimov 2021-08-11 11:08:07 +02:00 committed by GitHub
commit a3875d82d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import (
"github.com/icinga/icingadb/pkg/icingadb"
"github.com/icinga/icingadb/pkg/icingaredis"
"github.com/icinga/icingadb/pkg/utils"
goflags "github.com/jessevdk/go-flags"
"github.com/pkg/errors"
"go.uber.org/zap"
"os"
@ -23,7 +24,12 @@ type Command struct {
func New() *Command {
flags, err := config.ParseFlags()
if err != nil {
utils.Fatal(err)
var cliErr *goflags.Error
if errors.As(err, &cliErr) && cliErr.Type == goflags.ErrHelp {
os.Exit(0)
}
os.Exit(2)
}
if flags.Version {