From ba243381229754f15e03c7fe135e2565a61301ba Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 30 Jun 2023 15:55:13 +0200 Subject: [PATCH] Add quiet mode to nvidia-ctk cli Signed-off-by: Evan Lezar --- cmd/nvidia-ctk/main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/nvidia-ctk/main.go b/cmd/nvidia-ctk/main.go index a1566559..8cbb56c2 100644 --- a/cmd/nvidia-ctk/main.go +++ b/cmd/nvidia-ctk/main.go @@ -36,6 +36,8 @@ import ( type options struct { // Debug indicates whether the CLI is started in "debug" mode Debug bool + // Quiet indicates whether the CLI is started in "quiet" mode + Quiet bool } func main() { @@ -61,6 +63,12 @@ func main() { Destination: &opts.Debug, EnvVars: []string{"NVIDIA_CTK_DEBUG"}, }, + &cli.BoolFlag{ + Name: "quiet", + Usage: "Suppress all output except for errors; overrides --debug", + Destination: &opts.Quiet, + EnvVars: []string{"NVIDIA_CTK_QUIET"}, + }, } // Set log-level for all subcommands @@ -69,6 +77,9 @@ func main() { if opts.Debug { logLevel = logrus.DebugLevel } + if opts.Quiet { + logLevel = logrus.ErrorLevel + } logger.SetLevel(logLevel) return nil }