From 782e01ffe81266e98ba69532d9e36b9805d42b98 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 1 Dec 2018 20:23:32 -0800 Subject: [PATCH] add -version support to beaconchain app Signed-off-by: Leo Chen --- go_executable_build.sh | 1 + runbeacon/run-beacon.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/go_executable_build.sh b/go_executable_build.sh index a6a3fa482..a5e2ca340 100755 --- a/go_executable_build.sh +++ b/go_executable_build.sh @@ -2,6 +2,7 @@ declare -A SRC SRC[benchmark]=benchmark.go SRC[txgen]=client/txgen/main.go +SRC[beacon]=runbeacon/run-beacon.go BINDIR=bin BUCKET=unique-bucket-bin diff --git a/runbeacon/run-beacon.go b/runbeacon/run-beacon.go index 39a366cc9..42739dc40 100644 --- a/runbeacon/run-beacon.go +++ b/runbeacon/run-beacon.go @@ -2,15 +2,37 @@ package main import ( "flag" + "fmt" + "os" + "path" "github.com/harmony-one/harmony/beaconchain" ) +var ( + version string + builtBy string + builtAt string + commit string +) + +func printVersion(me string) { + fmt.Fprintf(os.Stderr, "Harmony (C) 2018. %v, version %v-%v (%v %v)\n", path.Base(me), version, commit, builtBy, builtAt) + os.Exit(0) +} + func main() { numShards := flag.Int("numShards", 1, "number of shards of identity chain") ip := flag.String("ip", "127.0.0.1", "ip on which beaconchain listens") port := flag.String("port", "8081", "port on which beaconchain listens") + versionFlag := flag.Bool("version", false, "Output version info") + flag.Parse() + + if *versionFlag { + printVersion(os.Args[0]) + } + bc := beaconchain.New(*numShards, *ip, *port) bc.StartServer() }