2021-02-14 00:42:47 +00:00
|
|
|
package lumecmd
|
|
|
|
|
2021-02-28 04:42:09 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2021-03-16 04:18:19 +00:00
|
|
|
"runtime"
|
2021-03-11 03:39:47 +00:00
|
|
|
"strings"
|
2021-02-28 04:42:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewCmdVersion() Command {
|
|
|
|
return Command{
|
|
|
|
Name: "version",
|
|
|
|
Func: VersionCmd,
|
|
|
|
Flags: nil,
|
|
|
|
Use: "",
|
|
|
|
Short: "Show version",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 00:23:50 +00:00
|
|
|
func VersionCmd(ctx Context) (int, error) {
|
2021-03-11 03:39:47 +00:00
|
|
|
var b strings.Builder
|
|
|
|
|
2021-03-16 04:18:19 +00:00
|
|
|
fmt.Fprintf(&b, "lume, version %s\n", Version)
|
|
|
|
|
2021-03-11 03:39:47 +00:00
|
|
|
if GitCommit != "" {
|
2021-03-16 04:18:19 +00:00
|
|
|
fmt.Fprintf(&b, " revision: %s\n", GitCommit)
|
2021-03-11 03:39:47 +00:00
|
|
|
}
|
2021-03-17 00:20:19 +00:00
|
|
|
|
2021-03-03 02:41:18 +00:00
|
|
|
if BuildDate != "" {
|
2021-03-16 04:18:19 +00:00
|
|
|
fmt.Fprintf(&b, " build date: %s\n", BuildDate)
|
2021-03-03 02:41:18 +00:00
|
|
|
}
|
2021-03-11 03:39:47 +00:00
|
|
|
|
2021-03-16 04:18:19 +00:00
|
|
|
fmt.Fprintf(&b, " go version: %s\n", runtime.Version())
|
2021-03-17 00:21:59 +00:00
|
|
|
fmt.Fprintf(&b, " platform: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
2021-03-16 04:18:19 +00:00
|
|
|
|
|
|
|
fmt.Print(b.String())
|
|
|
|
|
2021-02-28 04:42:09 +00:00
|
|
|
return ExitSuccess, nil
|
|
|
|
}
|