From f30756a9bb27099a7240b9c9bb7f5be2c516cdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 7 Jul 2018 02:48:17 +0200 Subject: [PATCH] Use globalOptions for the debug flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This works just like the command-specific options. Handles only the single flag for now, others will be added as the infrastructure is built. Signed-off-by: Miloslav Trmač --- cmd/skopeo/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/skopeo/main.go b/cmd/skopeo/main.go index 852e8cdf..3760f5fa 100644 --- a/cmd/skopeo/main.go +++ b/cmd/skopeo/main.go @@ -16,6 +16,7 @@ import ( var gitCommit = "" type globalOptions struct { + debug bool // Enable debug output } // createApp returns a cli.App to be run or tested. @@ -33,8 +34,9 @@ func createApp() *cli.App { app.Usage = "Various operations with container images and container image registries" app.Flags = []cli.Flag{ cli.BoolFlag{ - Name: "debug", - Usage: "enable debug output", + Name: "debug", + Usage: "enable debug output", + Destination: &opts.debug, }, cli.BoolTFlag{ Name: "tls-verify", @@ -86,7 +88,7 @@ func createApp() *cli.App { // before is run by the cli package for any command, before running the command-specific handler. func (opts *globalOptions) before(c *cli.Context) error { - if c.GlobalBool("debug") { + if opts.debug { logrus.SetLevel(logrus.DebugLevel) } if c.GlobalIsSet("tls-verify") {