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

@ -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() {