Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-04-09 20:36:10 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-04-11 10:48:56 +0300
commit56a13080446283ed1cde6b69fc6f4fac85076c84 (patch)
tree59316b9b8df2036aac0e8438c2ea31a6012c0802 /commands/version.go
parent4b780ca778ee7f25af808da38ede964a01698c70 (diff)
commands: Make the new commands non-global
See #4598
Diffstat (limited to 'commands/version.go')
-rw-r--r--commands/version.go30
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() {