Skip to content

Commit

Permalink
Removes flag globals (makes them local). Adds flag prefix. #16
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Gappa committed Sep 23, 2018
1 parent c5a49b0 commit b4ab887
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ")
}
Expand Down

0 comments on commit b4ab887

Please sign in to comment.