From c82309d2b4c4856e78457eb5252876b30b038574 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 24 Sep 2014 17:08:42 -0700 Subject: [PATCH] main: add version flag --- main.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 872e698e3..c52a1b53f 100644 --- a/main.go +++ b/main.go @@ -31,14 +31,17 @@ const ( proxyFlagValueOff = "off" proxyFlagValueReadonly = "readonly" proxyFlagValueOn = "on" + + version = "0.5.0-alpha" ) var ( - fid = flag.String("id", "0x1", "ID of this server") - timeout = flag.Duration("timeout", 10*time.Second, "Request Timeout") - paddr = flag.String("peer-bind-addr", ":7001", "Peer service address (e.g., ':7001')") - dir = flag.String("data-dir", "", "Path to the data directory") - snapCount = flag.Int64("snapshot-count", etcdserver.DefaultSnapCount, "Number of committed transactions to trigger a snapshot") + fid = flag.String("id", "0x1", "ID of this server") + timeout = flag.Duration("timeout", 10*time.Second, "Request Timeout") + paddr = flag.String("peer-bind-addr", ":7001", "Peer service address (e.g., ':7001')") + dir = flag.String("data-dir", "", "Path to the data directory") + snapCount = flag.Int64("snapshot-count", etcdserver.DefaultSnapCount, "Number of committed transactions to trigger a snapshot") + printVersion = flag.Bool("version", false, "Print the version and exit") peers = &etcdhttp.Peers{} addrs = &Addrs{} @@ -100,6 +103,11 @@ func main() { flag.Usage = pkg.UsageWithIgnoredFlagsFunc(flag.CommandLine, deprecated) flag.Parse() + if *printVersion { + fmt.Println("etcd version", version) + os.Exit(0) + } + pkg.SetFlagsFromEnv(flag.CommandLine) if string(*proxyFlag) == proxyFlagValueOff {