Skip to content

Commit

Permalink
Add version and flag to print it
Browse files Browse the repository at this point in the history
  • Loading branch information
conortm committed May 19, 2015
1 parent 48dc9bf commit 1eab62d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@ const usageMessage = `
members of teams and either print them or write them to authorized_keys files.
Pass a single 'username' argument to only print/write keys for that user.
Usage:
ghkeys [-config="/path/to/config.yml"] [-write] [username]
`

var (
// VERSION swapped out by `go build -ldflags "-X main.VERSION 1.2.3"`
VERSION = "0.0.3"
configFilename = flag.String("config", "config.yml", "Path to yaml config file")
debug = flag.Bool("d", false, "Add debugging output")
showVersion = flag.Bool("version", false, "Display the version number")
writeToFile = flag.Bool("write", false, "Write keys to users' authorized_keys files")
)

func printVersion() {
fmt.Printf("ghkeys version %s\n", VERSION)
}

func usage() {
printVersion()
fmt.Println(usageMessage + "\nFlags:")
flag.PrintDefaults()
}
Expand Down Expand Up @@ -85,6 +96,11 @@ func main() {
flag.Usage = usage
flag.Parse()

if *showVersion {
printVersion()
os.Exit(0)
}

config, err := newConfig(*configFilename)
check(err)
// TODO: validate config values
Expand Down

0 comments on commit 1eab62d

Please sign in to comment.