Skip to content

Commit

Permalink
add -v
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Jan 23, 2015
1 parent 2a27e76 commit b6e34d3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
consul-kv-dashboard
pkg/

# auto generated by go-bindata
bindata.go
Expand Down
13 changes: 12 additions & 1 deletion Makefile
@@ -1,6 +1,17 @@
consul-kv-dashboard: *.go bindata.go
GIT_VER := $(shell git describe --tags)

.PHONY: packages clean

consul-kv-dashboard: dashboard.go bindata.go
stringer -type=Status
go build

bindata.go: assets/index.html assets/scripts/dashboard.js
go-bindata -prefix=assets assets/...

packages: bindata.go dashboard.go
gox -os="linux darwin windows" -arch="amd64 386" -output "pkg/{{.Dir}}-${GIT_VER}-{{.OS}}-{{.Arch}}" -ldflags "-X main.version ${GIT_VER}"
cd pkg && find . -name "*${GIT_VER}*" -type f -exec zip {}.zip {} \;

clean:
rm -fr pkg/*
13 changes: 11 additions & 2 deletions dashboard.go
Expand Up @@ -17,6 +17,7 @@ import (
var (
Namespace = "dashboard"
ConsulAddr = "127.0.0.1:8500"
Version string
Nodes []Node
mutex sync.Mutex
)
Expand Down Expand Up @@ -81,14 +82,22 @@ type Node struct {

func main() {
var (
port int
assetDir string
port int
assetDir string
showVersion bool
)
flag.StringVar(&Namespace, "namespace", Namespace, "Consul kv top level key name. (/v1/kv/{namespace}/...)")
flag.IntVar(&port, "port", 3000, "http listen port")
flag.StringVar(&assetDir, "asset", "", "Serve files located in /assets from local directory. If not specified, use built-in asset.")
flag.BoolVar(&showVersion, "v", false, "show vesion")
flag.BoolVar(&showVersion, "version", false, "show vesion")
flag.Parse()

if showVersion {
fmt.Println("consul-kv-dashboard: version:", Version)
return
}

mux := http.NewServeMux()
mux.HandleFunc("/", indexPage)
mux.HandleFunc("/api/", kvApiProxy)
Expand Down

0 comments on commit b6e34d3

Please sign in to comment.