Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambiguous tags: use 'viper' and remove 'useViper' #1584

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cobra/cmd/add_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestGoldenAddCmd(t *testing.T) {
viper.Set("useViper", true)
viper.Set("viper", true)
viper.Set("license", "apache")
command := &Command{
CmdName: "test",
Expand Down
4 changes: 2 additions & 2 deletions cobra/cmd/init.go
Expand Up @@ -41,7 +41,7 @@ Cobra init must be run inside of a go module (please run "go mod init <MODNAME>"
projectPath, err := initializeProject(args)
cobra.CheckErr(err)
cobra.CheckErr(goGet("github.com/spf13/cobra"))
if viper.GetBool("useViper") {
if viper.GetBool("viper") {
cobra.CheckErr(goGet("github.com/spf13/viper"))
}
fmt.Printf("Your Cobra application is ready at\n%s\n", projectPath)
Expand All @@ -68,7 +68,7 @@ func initializeProject(args []string) (string, error) {
PkgName: modName,
Legal: getLicense(),
Copyright: copyrightLine(),
Viper: viper.GetBool("useViper"),
Viper: viper.GetBool("viper"),
AppName: path.Base(modName),
}

Expand Down
2 changes: 1 addition & 1 deletion cobra/cmd/init_test.go
Expand Up @@ -47,7 +47,7 @@ func TestGoldenInitCmd(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

viper.Set("useViper", true)
viper.Set("viper", true)
viper.Set("license", "apache")
projectPath, err := initializeProject(tt.args)
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion cobra/cmd/root.go
Expand Up @@ -48,7 +48,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
rootCmd.PersistentFlags().Bool("viper", false, "use Viper for configuration")
cobra.CheckErr(viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author")))
cobra.CheckErr(viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper")))
cobra.CheckErr(viper.BindPFlag("viper", rootCmd.PersistentFlags().Lookup("viper")))
viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
viper.SetDefault("license", "none")

Expand Down
2 changes: 1 addition & 1 deletion user_guide.md
Expand Up @@ -107,7 +107,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
rootCmd.PersistentFlags().Bool("viper", true, "use Viper for configuration")
viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))
viper.BindPFlag("viper", rootCmd.PersistentFlags().Lookup("viper"))
viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
viper.SetDefault("license", "apache")

Expand Down