diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-09 19:36:10 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-11 09:48:56 +0200 |
commit | 56a13080446283ed1cde6b69fc6f4fac85076c84 (patch) | |
tree | 59316b9b8df2036aac0e8438c2ea31a6012c0802 /commands/version.go | |
parent | 4b780ca778ee7f25af808da38ede964a01698c70 (diff) |
commands: Make the new commands non-global
See #4598
Diffstat (limited to 'commands/version.go')
-rw-r--r-- | commands/version.go | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/commands/version.go b/commands/version.go index 4f3810c78..978a5440d 100644 --- a/commands/version.go +++ b/commands/version.go @@ -23,14 +23,28 @@ import ( jww "github.com/spf13/jwalterweatherman" ) -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Print the version number of Hugo", - Long: `All software has versions. This is Hugo's.`, - RunE: func(cmd *cobra.Command, args []string) error { - printHugoVersion() - return nil - }, +var _ cmder = (*versionCmd)(nil) + +type versionCmd struct { + cmd *cobra.Command +} + +func newVersionCmd() *versionCmd { + return &versionCmd{ + &cobra.Command{ + Use: "version", + Short: "Print the version number of Hugo", + Long: `All software has versions. This is Hugo's.`, + RunE: func(cmd *cobra.Command, args []string) error { + printHugoVersion() + return nil + }, + }, + } +} + +func (c *versionCmd) getCommand() *cobra.Command { + return c.cmd } func printHugoVersion() { |