package zm_lib import ( "complie-erlang/cache" "fmt" "github.com/spf13/cobra" ) func PersistentFlagsStringVar(cmd *cobra.Command, varK *string, cache cache.Cache, globalKey string, defaultValue string, desc string) error { pluginKey := fmt.Sprintf("%s.%s", cmd.Use, globalKey) plugin, err := cache.GetDefault(pluginKey, defaultValue) cmd.PersistentFlags().StringVar(varK, globalKey, plugin.(string), fmt.Sprintf("%s (global.key:\"%s\")", desc, pluginKey)) return err }