2017-07-19 22:06:43 +02:00
|
|
|
package commands
|
2017-07-05 17:18:46 +02:00
|
|
|
|
2017-07-18 15:34:54 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Make initializes Version to the git commit hash, and BuildDate.
|
|
|
|
var (
|
|
|
|
Version string
|
|
|
|
BuildDate string
|
|
|
|
BuildTime time.Time
|
|
|
|
)
|
2017-07-05 17:18:46 +02:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
if Version == "" {
|
|
|
|
Version = "develop"
|
|
|
|
}
|
2017-07-18 15:34:54 +02:00
|
|
|
if BuildDate != "" {
|
|
|
|
bd, err := time.Parse("2006-01-02T15:04:05-0700", BuildDate)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, "invalid BuildDate", BuildDate) // nolint: gas
|
|
|
|
} else {
|
|
|
|
BuildTime = bd.In(time.UTC)
|
|
|
|
}
|
|
|
|
}
|
2017-07-05 17:18:46 +02:00
|
|
|
}
|
2017-08-11 19:25:51 +02:00
|
|
|
|
|
|
|
var versionCmd = app.Command("version", "Print the name and version")
|
|
|
|
|
|
|
|
func versionCommand() error {
|
|
|
|
var d string
|
|
|
|
if !BuildTime.IsZero() {
|
|
|
|
d = BuildTime.Format(" (Build time: 2006-01-02T15:04)")
|
|
|
|
}
|
|
|
|
fmt.Printf("gojekyll version %s%s\n", Version, d)
|
|
|
|
return nil
|
|
|
|
}
|