From d2b1d64de32f9fb41d8fcac5fc0a7d44bf0600be Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Thu, 24 Jul 2014 16:30:45 -0400 Subject: [PATCH 1/2] Add version numbers and ARM build --- .goxc.json | 2 +- cayley.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.goxc.json b/.goxc.json index 2742cab..538f98c 100644 --- a/.goxc.json +++ b/.goxc.json @@ -1,5 +1,5 @@ { - "Arch": "amd64 386", + "Arch": "arm amd64 386", "Os": "linux darwin windows", "ResourcesInclude": "README.md,static,templates,LICENSE,AUTHORS,CONTRIBUTORS,docs,cayley.cfg.example,30kmoviedata.nq.gz,testdata.nq", "ConfigVersion": "0.9" diff --git a/cayley.go b/cayley.go index 87bf18b..49392c7 100644 --- a/cayley.go +++ b/cayley.go @@ -40,6 +40,10 @@ var cpuprofile = flag.String("prof", "", "Output profiling file.") var queryLanguage = flag.String("query_lang", "gremlin", "Use this parser as the query language.") var configFile = flag.String("config", "", "Path to an explicit configuration file.") +// Filled in by `go build ldflags="-X main.VERSION `ver`"`. +var BUILD_DATE string +var VERSION string + func Usage() { fmt.Println("Cayley is a graph store and graph query layer.") fmt.Println("\nUsage:") @@ -52,6 +56,9 @@ func Usage() { fmt.Println("\nFlags:") flag.Parse() flag.PrintDefaults() + if VERSION != "" { + fmt.Printf("Release v%s\n", VERSION) + } } func main() { @@ -68,6 +75,10 @@ func main() { os.Args = newargs flag.Parse() + if VERSION != "" { + glog.Info("Cayley v", VERSION, " built ", BUILD_DATE) + } + cfg := config.ParseConfigFromFlagsAndFile(*configFile) if os.Getenv("GOMAXPROCS") == "" { From 8136f2abe99ffbb479baa33c733d6ea51f68f7ac Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Wed, 30 Jul 2014 18:02:40 -0400 Subject: [PATCH 2/2] fix usage to make more sense --- cayley.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/cayley.go b/cayley.go index 49392c7..c68d487 100644 --- a/cayley.go +++ b/cayley.go @@ -49,16 +49,14 @@ func Usage() { fmt.Println("\nUsage:") fmt.Println(" cayley COMMAND [flags]") fmt.Println("\nCommands:") - fmt.Println(" init\tCreate an empty database.") - fmt.Println(" load\tBulk-load a triple file into the database.") - fmt.Println(" http\tServe an HTTP endpoint on the given host and port.") - fmt.Println(" repl\tDrop into a REPL of the given query language.") + fmt.Println(" init Create an empty database.") + fmt.Println(" load Bulk-load a triple file into the database.") + fmt.Println(" http Serve an HTTP endpoint on the given host and port.") + fmt.Println(" repl Drop into a REPL of the given query language.") + fmt.Println(" version Version information.") fmt.Println("\nFlags:") flag.Parse() flag.PrintDefaults() - if VERSION != "" { - fmt.Printf("Release v%s\n", VERSION) - } } func main() { @@ -69,14 +67,16 @@ func main() { } cmd := os.Args[1] - newargs := make([]string, 0) + var newargs []string newargs = append(newargs, os.Args[0]) newargs = append(newargs, os.Args[2:]...) os.Args = newargs flag.Parse() + var buildString string if VERSION != "" { - glog.Info("Cayley v", VERSION, " built ", BUILD_DATE) + buildString = fmt.Sprint("Cayley ", VERSION, " built ", BUILD_DATE) + glog.Infoln(buildString) } cfg := config.ParseConfigFromFlagsAndFile(*configFile) @@ -93,6 +93,13 @@ func main() { err error ) switch cmd { + case "version": + if VERSION != "" { + fmt.Println(buildString) + } else { + fmt.Println("Cayley snapshot") + } + os.Exit(0) case "init": err = db.Init(cfg, *tripleFile) case "load":