diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-05 10:20:25 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-05 10:20:25 +0200 |
commit | 2a4ed1c49259d170a2aa985a603c8a5bed00ff67 (patch) | |
tree | cc934fb626f7a1d7e2fb360deac01a9c4e1ea6fb /commands/version.go | |
parent | 80367ea218d653dd21010695d71ddcaa001873da (diff) |
Add hugo env command
Useful for bug reports.
Fixes #2523
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 |