From 7dbfe8db2f01348f169513c0eed7c69bc2269b93 Mon Sep 17 00:00:00 2001 From: Zane Durkin Date: Sat, 17 Sep 2022 16:32:52 +0000 Subject: [PATCH] Adding quiet mode to silence banner (#852) * Adding quiet mode to silence banner * Changing flag description. Adding flag to README * Updating argument name * updating variable name to aline with argument * fixing readme spacing * Fixing variable name --- README.md | 1 + cmd/root.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9ced3160..6f86423de 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ Flags: --exit-code string exit code when leaks have been encountered (default: 1) -h, --help help for gitleaks -l, --log-level string log level (debug, info, warn, error, fatal) (default "info") + --no-banner suppress banner --redact redact secrets from logs and stdout -f, --report-format string output format (json, csv, sarif) -r, --report-path string report file diff --git a/cmd/root.go b/cmd/root.go index 19cd721bb..7ed0e991e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -46,6 +46,7 @@ func init() { rootCmd.PersistentFlags().StringP("log-level", "l", "info", "log level (trace, debug, info, warn, error, fatal)") rootCmd.PersistentFlags().BoolP("verbose", "v", false, "show verbose output from scan") rootCmd.PersistentFlags().Bool("redact", false, "redact secrets from logs and stdout") + rootCmd.PersistentFlags().Bool("no-banner", false, "suppress banner") err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config")) if err != nil { log.Fatal().Msgf("err binding config %s", err.Error()) @@ -77,7 +78,10 @@ func initLog() { } func initConfig() { - fmt.Fprint(os.Stderr, banner) + hideBanner, err := rootCmd.Flags().GetBool("no-banner") + if !hideBanner { + fmt.Fprint(os.Stderr, banner) + } cfgPath, err := rootCmd.Flags().GetString("config") if err != nil { log.Fatal().Msg(err.Error())