Add kpod version

Signed-off-by: umohnani8 <umohnani@redhat.com>
This commit is contained in:
umohnani8 2017-06-16 12:27:06 -04:00
parent 91977d3989
commit 9595d7900e
7 changed files with 107 additions and 2 deletions

View file

@ -7,14 +7,18 @@ import (
"github.com/urfave/cli"
)
//Version of kpod
const Version string = "0.0.1"
func main() {
app := cli.NewApp()
app.Name = "kpod"
app.Usage = "manage pods and images"
app.Version = "0.0.1"
app.Version = Version
app.Commands = []cli.Command{
launchCommand,
versionCommand,
}
if err := app.Run(os.Args); err != nil {

43
cmd/kpod/version.go Normal file
View file

@ -0,0 +1,43 @@
package main
import (
"fmt"
"runtime"
"strconv"
"time"
"github.com/urfave/cli"
)
// Overwritten at build time
var (
gitCommit string
buildInfo string
)
// versionCmd gets and prints version info for version command
func versionCmd(c *cli.Context) error {
// Converts unix time from string to int64
buildTime, err := strconv.ParseInt(buildInfo, 10, 64)
if err != nil {
return err
}
fmt.Println("Version: ", Version)
fmt.Println("Go Version: ", runtime.Version())
fmt.Println("Git Commit: ", gitCommit)
// Prints out the build time in readable format
fmt.Println("Built: ", time.Unix(buildTime, 0).Format(time.ANSIC))
fmt.Println("OS/Arch: ", runtime.GOOS+"/"+runtime.GOARCH)
return nil
}
// Cli command to print out the full version of kpod
var versionCommand = cli.Command{
Name: "version",
Usage: "Display the KPOD Version Information",
Action: versionCmd,
}