Skip to content

Commit

Permalink
add version subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
justone committed Aug 4, 2015
1 parent 1299b4c commit bc9c9a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ echo
# use bundled versions
export GOPATH=`godep path`:$GOPATH

gox -osarch="darwin/amd64 linux/amd64 linux/arm"
gox -ldflags "-X main.version $VERSION" -osarch="darwin/amd64 linux/amd64 linux/arm"

mkdir $VERSION

Expand Down
29 changes: 29 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import "fmt"

type VersionCommand struct {
// nothing yet
}

var versionCommand VersionCommand

var version string

func (x *VersionCommand) Execute(args []string) error {

if len(version) == 0 {
fmt.Println("unknown version, compiled from git")
} else {
fmt.Println("version:", version)
}

return nil
}

func init() {
parser.AddCommand("version",
"Print the version number.",
"",
&versionCommand)
}

0 comments on commit bc9c9a5

Please sign in to comment.