Skip to content

Commit

Permalink
Add -version
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilder committed May 20, 2014
1 parent 613bd8d commit ac12a4d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
.SILENT :
.PHONY : docker-gen clean fmt

TAG:=`git describe --abbrev=0 --tags`
LDFLAGS:=-X main.buildVersion $(TAG)

all: docker-gen

docker-gen:
echo "Building docker-gen"
go build
go build -ldflags "$(LDFLAGS)"

dist-clean:
rm -rf dist
Expand All @@ -17,5 +20,5 @@ dist: dist-clean

release: dist
godep restore
tar -cvzf docker-gen-linux-amd64-latest.tar.gz -C dist/linux/amd64 docker-gen
tar -cvzf docker-gen-linux-i386-latest.tar.gz -C dist/linux/i386 docker-gen
tar -cvzf docker-gen-linux-amd64-$(TAG).tar.gz -C dist/linux/amd64 docker-gen
tar -cvzf docker-gen-linux-i386-$(TAG).tar.gz -C dist/linux/i386 docker-gen
8 changes: 8 additions & 0 deletions docker-gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
)

var (
buildVersion string
version bool
watch bool
notifyCmd string
onlyExposed bool
Expand Down Expand Up @@ -198,6 +200,7 @@ func generateFromEvents(client *docker.Client, configs ConfigFile) {
}

func initFlags() {
flag.BoolVar(&version, "version", false, "show version")
flag.BoolVar(&watch, "watch", false, "watch for container changes")
flag.BoolVar(&onlyExposed, "only-exposed", false, "only include containers with exposed ports")
flag.BoolVar(&onlyPublished, "only-published", false, "only include containers with published ports (implies -only-exposed)")
Expand All @@ -211,6 +214,11 @@ func initFlags() {
func main() {
initFlags()

if version {
fmt.Println(buildVersion)
return
}

if flag.NArg() < 1 && configFile == "" {
usage()
os.Exit(1)
Expand Down

0 comments on commit ac12a4d

Please sign in to comment.