Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #462

authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent d7cfb13 · Browse files · 1 file+9 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−9 removed

  • other:+9 added−9 removed

1 file+9 added−9 removed

modified:cobra/cmd/init.go+9 added-9 removed
57 unmodified lines
58 } else {59 project = NewProject(arg)60 }61 } else {62 er("please enter the name")62 er("please provide only one argument")63 }6465 initializeProject(project)66
75 unmodified lines
142import (143 "fmt"144 "os"145146 homedir "github.com/mitchellh/go-homedir"147 "github.com/spf13/cobra"148{{if .viper}} "github.com/spf13/viper"{{end}}149)146 "github.com/spf13/cobra"{{if .viper}}147 "github.com/spf13/viper"148 homedir "github.com/mitchellh/go-homedir"{{end}}149){{if .viper}}150151{{if .viper}}var cfgFile string{{end}}151var cfgFile string{{end}}152153// RootCmd represents the base command when called without any subcommands154var RootCmd = &cobra.Command{155 Use: "{{.appName}}",
17 unmodified lines
173 os.Exit(1)174 }175}176177func init() {178{{if .viper}} cobra.OnInitialize(initConfig){{end}}179177func init() { {{if .viper}}178 cobra.OnInitialize(initConfig)179 {{end}}180 // Here you will define your flags and configuration settings.181 // Cobra supports persistent flags, which, if defined here,182 // will be global for your application.{{ if .viper }}183 RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.{{ .appName }}.yaml)"){{ else }}
51 unmodified lines