Add "extended" to "hugo version"
authorAnthony Fok <foka@debian.org>
Sun, 8 Jul 2018 08:45:13 +0000 (02:45 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 8 Jul 2018 09:08:54 +0000 (11:08 +0200)
Fixes #4913

commands/version.go

index dfa79bb69657c367a013e3aa84f5d5adbad74bc8..ea4e4c926c001706187a57ce3e3451a641699dc0 100644 (file)
@@ -19,6 +19,7 @@ import (
 
        "github.com/gohugoio/hugo/helpers"
        "github.com/gohugoio/hugo/hugolib"
+       "github.com/gohugoio/hugo/resource/tocss/scss"
        "github.com/spf13/cobra"
        jww "github.com/spf13/jwalterweatherman"
 )
@@ -44,13 +45,24 @@ func newVersionCmd() *versionCmd {
 }
 
 func printHugoVersion() {
-       if hugolib.CommitHash == "" {
-               if hugolib.BuildDate == "" {
-                       jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH)
-               } else {
-                       jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
-               }
+       program := "Hugo Static Site Generator"
+
+       version := "v" + helpers.CurrentHugoVersion.String()
+       if hugolib.CommitHash != "" {
+               version += "-" + strings.ToUpper(hugolib.CommitHash)
+       }
+       if scss.Supports() {
+               version += "/extended"
+       }
+
+       osArch := runtime.GOOS + "/" + runtime.GOARCH
+
+       var buildDate string
+       if hugolib.BuildDate != "" {
+               buildDate = hugolib.BuildDate
        } else {
-               jww.FEEDBACK.Printf("Hugo Static Site Generator v%s-%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, strings.ToUpper(hugolib.CommitHash), runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
+               buildDate = "unknown"
        }
+
+       jww.FEEDBACK.Println(program, version, osArch, "BuildDate:", buildDate)
 }