1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package app
- import (
- "fmt"
- "os"
- "runtime"
- "text/template"
- "github.com/Sirupsen/logrus"
- "github.com/codegangsta/cli"
- "github.com/docker/libcompose/version"
- )
- var versionTemplate = `Version: {{.Version}} ({{.GitCommit}})
- Go version: {{.GoVersion}}
- Built: {{.BuildTime}}
- OS/Arch: {{.Os}}/{{.Arch}}`
- // Version prints the libcompose version number and additionnal informations.
- func Version(c *cli.Context) {
- if c.Bool("short") {
- fmt.Println(version.VERSION)
- return
- }
- tmpl, err := template.New("").Parse(versionTemplate)
- if err != nil {
- logrus.Fatal(err)
- }
- v := struct {
- Version string
- GitCommit string
- GoVersion string
- BuildTime string
- Os string
- Arch string
- }{
- Version: version.VERSION,
- GitCommit: version.GITCOMMIT,
- GoVersion: runtime.Version(),
- BuildTime: version.BUILDTIME,
- Os: runtime.GOOS,
- Arch: runtime.GOARCH,
- }
- if err := tmpl.Execute(os.Stdout, v); err != nil {
- logrus.Fatal(err)
- }
- fmt.Printf("\n")
- return
- }
|