From b4ab887eb73d4933fd7d616370ba7f3e01ce629f Mon Sep 17 00:00:00 2001 From: Mariano Gappa Date: Sun, 23 Sep 2018 16:27:09 +1200 Subject: [PATCH] Removes flag globals (makes them local). Adds flag prefix. #16 --- main.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 255ac37..84d6ffc 100644 --- a/main.go +++ b/main.go @@ -20,19 +20,17 @@ type database struct { Pass string } -var help = flag.Bool("help", false, "shows usage") -var listDBs = flag.Bool("list-dbs", false, "List all available DBs (used for auto-completion)") - -func init() { - flag.BoolVar(help, "h", false, "shows usage") -} - func main() { + var ( + flagHelp = flag.Bool("help", false, "shows usage") + flagListDBs = flag.Bool("list-dbs", false, "List all available DBs (used for auto-completion)") + ) + flag.BoolVar(flagHelp, "h", false, "shows usage") flag.Parse() - if *help { + if *flagHelp { usage("") } - if *listDBs { // for auto-completion + if *flagListDBs { // for auto-completion for dbName := range mustReadDatabasesConfigFile() { fmt.Print(dbName, " ") }