From 7bb82574204b2e12ef470b7d6f0abbe91ec0c2c0 Mon Sep 17 00:00:00 2001 From: erinn Date: Mon, 25 Mar 2019 12:10:46 -0700 Subject: [PATCH] proper flag parsing --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 16352f67..83867ebf 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "cwtch.im/ui/go/gobjects" "cwtch.im/ui/go/gothings" "cwtch.im/ui/go/the" + "flag" "fmt" "git.openprivacy.ca/openprivacy/libricochet-go/connectivity" "git.openprivacy.ca/openprivacy/libricochet-go/log" @@ -30,8 +31,11 @@ func init() { } func main() { + flagDebug := flag.Bool("debug", false, "turn on extra logging. WARNING: THIS MAY EXPOSE PRIVATE INFORMATION IN CONSOLE OUTPUT!") + flagLocal := flag.Bool("local", false, "load user interface from the local folder \"qml\" instead of the built-in UI") + flag.Parse() - if len(os.Args) >= 3 && os.Args[2] == "-debug" { + if *flagDebug { log.SetLevel(log.LevelDebug) } else { log.SetLevel(log.LevelInfo) @@ -48,7 +52,7 @@ func main() { // this is to load local qml files quickly when developing var qmlSource *core.QUrl - if len(os.Args) >= 2 && os.Args[1] == "-local" { + if *flagLocal { qmlSource = core.QUrl_FromLocalFile("./qml/main.qml") } else { qmlSource = core.NewQUrl3("qrc:/qml/main.qml", 0)