Skip to content

Commit

Permalink
Add version flag
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Yousuf <[email protected]>
  • Loading branch information
alyyousuf7 committed May 18, 2018
1 parent a8e8e3e commit 548fde7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/twenty48/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
)

// build variables
var (
version = "dev"
commit = "none"
date = "unknown"
)

func PrintVersion() {
fmt.Printf("version: %s\ncommit: %s\nbuild at: %s\n", version, commit, date)
}
8 changes: 8 additions & 0 deletions cmd/twenty48/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ import (
)

var (
fVersion bool

fWidth int
fHeight int
)

func init() {
flag.BoolVar(&fVersion, "version", false, "")
flag.IntVar(&fWidth, "width", 8, "board width")
flag.IntVar(&fHeight, "height", 8, "board height")
}

func main() {
flag.Parse()

if fVersion {
PrintVersion()
return
}

startGame(fWidth, fHeight)
}

0 comments on commit 548fde7

Please sign in to comment.