diff options
Diffstat (limited to 'commands/version.go')
-rw-r--r-- | commands/version.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/commands/version.go b/commands/version.go index 932005939..d64a6cf6f 100644 --- a/commands/version.go +++ b/commands/version.go @@ -31,21 +31,25 @@ var versionCmd = &cobra.Command{ Short: "Print the version number of Hugo", Long: `All software has versions. This is Hugo's.`, RunE: func(cmd *cobra.Command, args []string) error { - if hugolib.BuildDate == "" { - setBuildDate() // set the build date from executable's mdate - } else { - formatBuildDate() // format the compile time - } - if hugolib.CommitHash == "" { - fmt.Printf("Hugo Static Site Generator v%s BuildDate: %s\n", helpers.HugoVersion(), hugolib.BuildDate) - } else { - fmt.Printf("Hugo Static Site Generator v%s-%s BuildDate: %s\n", helpers.HugoVersion(), strings.ToUpper(hugolib.CommitHash), hugolib.BuildDate) - } + printHugoVersion() return nil }, } +func printHugoVersion() { + if hugolib.BuildDate == "" { + setBuildDate() // set the build date from executable's mdate + } else { + formatBuildDate() // format the compile time + } + if hugolib.CommitHash == "" { + fmt.Printf("Hugo Static Site Generator v%s BuildDate: %s\n", helpers.HugoVersion(), hugolib.BuildDate) + } else { + fmt.Printf("Hugo Static Site Generator v%s-%s BuildDate: %s\n", helpers.HugoVersion(), strings.ToUpper(hugolib.CommitHash), hugolib.BuildDate) + } +} + // setBuildDate checks the ModTime of the Hugo executable and returns it as a // formatted string. This assumes that the executable name is Hugo, if it does // not exist, an empty string will be returned. This is only called if the |