return 1 with incomplete command line; always check error when calling cmd.Help (#1335)

This commit is contained in:
mmetc 2022-03-10 13:55:25 +01:00 committed by GitHub
parent 4e6b9597f8
commit aca37a38e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 22 deletions

View file

@ -20,10 +20,18 @@ import (
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/prom2json"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/mod/semver"
"gopkg.in/yaml.v2"
)
func printHelp(cmd *cobra.Command) {
err := cmd.Help()
if err != nil {
log.Fatalf("uname to print help(): %s", err)
}
}
func inSlice(s string, slice []string) bool {
for _, str := range slice {
if s == str {