mirror of
https://github.com/spf13/cobra
synced 2025-05-05 04:47:22 +00:00
Fix ambiguous tags: use 'viper' and remove 'useViper'
This commit is contained in:
parent
e04ec72550
commit
131e05a8f2
5 changed files with 6 additions and 6 deletions
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue