commands: Make the new commands non-global

See #4598
This commit is contained in:
Bjørn Erik Pedersen 2018-04-09 19:36:10 +02:00
parent 4b780ca778
commit 56a1308044
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
7 changed files with 415 additions and 271 deletions

View file

@ -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())
var _ cmder = (*envCmd)(nil)
return 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
},
},
}
}