cmd: Fix output root.go of init with --viper=false

Fix #462
This commit is contained in:
Albert Nigmatzianov 2017-06-12 08:23:33 +02:00
parent d7cfb13474
commit defa97f560

View file

@ -59,7 +59,7 @@ Init will not use an existing directory with contents.`,
project = NewProject(arg) project = NewProject(arg)
} }
} else { } else {
er("please enter the name") er("please provide only one argument")
} }
initializeProject(project) initializeProject(project)
@ -143,12 +143,12 @@ import (
"fmt" "fmt"
"os" "os"
homedir "github.com/mitchellh/go-homedir" "github.com/spf13/cobra"{{if .viper}}
"github.com/spf13/cobra" "github.com/spf13/viper"
{{if .viper}} "github.com/spf13/viper"{{end}} homedir "github.com/mitchellh/go-homedir"{{end}}
) ){{if .viper}}
{{if .viper}}var cfgFile string{{end}} var cfgFile string{{end}}
// RootCmd represents the base command when called without any subcommands // RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{ var RootCmd = &cobra.Command{
@ -174,9 +174,9 @@ func Execute() {
} }
} }
func init() { func init() { {{if .viper}}
{{if .viper}} cobra.OnInitialize(initConfig){{end}} cobra.OnInitialize(initConfig)
{{end}}
// Here you will define your flags and configuration settings. // Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here, // Cobra supports persistent flags, which, if defined here,
// will be global for your application.{{ if .viper }} // will be global for your application.{{ if .viper }}