lume/cmd/version.go

34 lines
533 B
Go
Raw Permalink Normal View History

2021-02-14 00:42:47 +00:00
package lumecmd
2021-02-28 04:42:09 +00:00
import (
"fmt"
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",
}
}
func VersionCmd(args CmdArgs) (int, error) {
2021-03-11 03:39:47 +00:00
var b strings.Builder
fmt.Fprintf(&b, "lume %s", Version)
b.WriteString(" ")
if GitCommit != "" {
fmt.Fprintf(&b, "(git: %s)", GitCommit)
b.WriteString(" ")
}
2021-03-03 02:41:18 +00:00
if BuildDate != "" {
2021-03-11 03:39:47 +00:00
fmt.Fprintf(&b, "build_date: %s", BuildDate)
2021-03-03 02:41:18 +00:00
}
2021-03-11 03:39:47 +00:00
fmt.Println(b.String())
2021-02-28 04:42:09 +00:00
return ExitSuccess, nil
}