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/env.go
parent4b780ca778ee7f25af808da38ede964a01698c70 (diff)
commands: Make the new commands non-global
See #4598
Diffstat (limited to 'commands/env.go')
-rw-r--r--commands/env.go35
1 files changed, 24 insertions, 11 deletions
diff --git a/commands/env.go b/commands/env.go
index 54c98d527..700cddf5a 100644
--- a/commands/env.go
+++ b/commands/env.go
@@ -20,16 +20,29 @@ import (
jww "github.com/spf13/jwalterweatherman"
)
-var envCmd = &cobra.Command{
- Use: "env",
- Short: "Print Hugo version and environment info",
- Long: `Print Hugo version and environment info. This is useful in Hugo bug reports.`,
- RunE: func(cmd *cobra.Command, args []string) error {
- printHugoVersion()
- jww.FEEDBACK.Printf("GOOS=%q\n", runtime.GOOS)
- jww.FEEDBACK.Printf("GOARCH=%q\n", runtime.GOARCH)
- jww.FEEDBACK.Printf("GOVERSION=%q\n", runtime.Version())
-
- return nil
+var _ cmder = (*envCmd)(nil)
+
+type envCmd struct {
+ cmd *cobra.Command
+}
+
+func (c *envCmd) getCommand() *cobra.Command {
+ return c.cmd
+}
+
+func newEnvCmd() *envCmd {
+ return &envCmd{cmd: &cobra.Command{
+ Use: "env",
+ Short: "Print Hugo version and environment info",
+ Long: `Print Hugo version and environment info. This is useful in Hugo bug reports.`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ printHugoVersion()
+ jww.FEEDBACK.Printf("GOOS=%q\n", runtime.GOOS)
+ jww.FEEDBACK.Printf("GOARCH=%q\n", runtime.GOARCH)
+ jww.FEEDBACK.Printf("GOVERSION=%q\n", runtime.Version())
+
+ return nil
+ },
},
+ }
}