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/env.go | |
parent | 4b780ca778ee7f25af808da38ede964a01698c70 (diff) |
commands: Make the new commands non-global
See #4598
Diffstat (limited to 'commands/env.go')
-rw-r--r-- | commands/env.go | 35 |
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 + }, }, + } } |