Permalink
Browse files

commands: Make the new commands non-global

See #4598
  • Loading branch information...
bep committed Apr 9, 2018
1 parent 4b780ca commit 56a13080446283ed1cde6b69fc6f4fac85076c84
Showing with 412 additions and 268 deletions.
  1. +24 −11 commands/env.go
  2. +3 −3 commands/hugo.go
  3. +32 −239 commands/new.go
  4. +14 −7 commands/{new_test.go → new_content_test.go}
  5. +152 −0 commands/new_site.go
  6. +165 −0 commands/new_theme.go
  7. +22 −8 commands/version.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
},
},
}
}
@@ -194,13 +194,13 @@ func Execute() {
// AddCommands adds child commands to the root command HugoCmd.
func AddCommands() {
HugoCmd.AddCommand(serverCmd)
HugoCmd.AddCommand(versionCmd)
HugoCmd.AddCommand(envCmd)
HugoCmd.AddCommand(newVersionCmd().getCommand())
HugoCmd.AddCommand(newEnvCmd().getCommand())
HugoCmd.AddCommand(configCmd)
HugoCmd.AddCommand(newCheckCmd().getCommand())
HugoCmd.AddCommand(newBenchmarkCmd().getCommand())
HugoCmd.AddCommand(newConvertCmd().getCommand())
HugoCmd.AddCommand(newCmd)
HugoCmd.AddCommand(newNewCmd().getCommand())
HugoCmd.AddCommand(listCmd)
HugoCmd.AddCommand(importCmd)
Oops, something went wrong.

0 comments on commit 56a1308

Please sign in to comment.