Permalink
Browse files

add version subcommand

  • Loading branch information...
justone committed Aug 4, 2015
1 parent 1299b4c commit bc9c9a565cb0fe2651b569a7cfbc658a5aa71005
Showing with 30 additions and 1 deletion.
  1. +1 −1 build.sh
  2. +29 −0 version.go
View
@@ -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
View
@@ -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.