diff --git a/cmd/twenty48/build.go b/cmd/twenty48/build.go new file mode 100644 index 0000000..ac238ce --- /dev/null +++ b/cmd/twenty48/build.go @@ -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) +} diff --git a/cmd/twenty48/main.go b/cmd/twenty48/main.go index 540b7c6..cb97a5f 100644 --- a/cmd/twenty48/main.go +++ b/cmd/twenty48/main.go @@ -5,11 +5,14 @@ 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") } @@ -17,5 +20,10 @@ func init() { func main() { flag.Parse() + if fVersion { + PrintVersion() + return + } + startGame(fWidth, fHeight) }