From fdae4c43486baa7baefea409725563c55b8b08a2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 14 Nov 2023 20:33:49 +0100 Subject: Add `--debug` flag Condition printing debug output on the presence of this flag. --- cmd/swextreload/main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/swextreload/main.go b/cmd/swextreload/main.go index 1b56eb6..f11a1e1 100644 --- a/cmd/swextreload/main.go +++ b/cmd/swextreload/main.go @@ -31,6 +31,12 @@ func main() { Type: "bool", Description: "show the program version", }, + { + LongName: "debug", + Type: "bool", + DefaultValue: false, + Description: "print debug output", + }, }, Positionals: []claw.Positional{ { @@ -46,8 +52,6 @@ func main() { log.Fatal(err) } - log.Printf("args: %#v", args) - socket_url, ok := args["socket-url"].(string) if !ok { fmt.Fprintln(os.Stderr, "error: '--socket-url' is required") @@ -60,6 +64,15 @@ func main() { os.Exit(sysexits.Usage) } + isDebug := args["debug"].(bool) + if isDebug { + swextreload.SetDebugOn() + } + + if isDebug { + log.Printf("args: %#v", args) + } + err = swextreload.Reload( socket_url, extension_ids, -- cgit v1.2.3