Skip to content

Commit

Permalink
Simplify version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jun 17, 2020
1 parent f8b386a commit d9d429f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions main.go
Expand Up @@ -18,7 +18,6 @@ package main

import (
"errors"
"flag"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -76,9 +75,7 @@ func main() {

gmx := NewGomuks(MainUIProvider, configDir, dataDir, cacheDir, downloadDir)

isVersion := flag.Bool("version", false, "Display gomuks version and exit")
flag.Parse()
if *isVersion {
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
fmt.Printf("gomuks version %s\n", gmx.Version())
os.Exit(0)
}
Expand Down

1 comment on commit d9d429f

@aaronraimist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to note, there was a slight benefit to using the flag thing. If you provided the wrong flag it would tell you

⟩ ./gomuks -versioN
flag provided but not defined: -versioN
Usage of ./gomuks:
  -version
    	Display gomuks version and exit

and it did --help

⟩ ./gomuks --help
Usage of ./gomuks:
  -version
    	if true, print version and exit

Please sign in to comment.