Documentation ¶
Index ¶
- Variables
- func BindCollectionItem(c *cobra.Command, rawVal interface{}, options ...func(*BindCollectionOptions))
- func BindCollectionItemFields(colField string, selectField string, c *cobra.Command, rawVal interface{})
- func BindFlags(c *cobra.Command, rawVal interface{}, options ...func(*BindOptions))
- func BindFlagsKey(key string, c *cobra.Command, rawVal interface{})
- func BindPersistentFlags(c *cobra.Command, rawVal interface{}, options ...func(*BindOptions))
- func BindPersistentFlagsKey(key string, c *cobra.Command, rawVal interface{})
- func BindTo(rawVal interface{}) func(*BindCollectionOptions)
- func Collection(collection *[]map[string]interface{}) func(*BindCollectionOptions)
- func CollectionField(name string) func(*BindCollectionOptions)
- func Get(key string) interface{}
- func GetInt(key string) int
- func GetString(key string) string
- func IdField(name string) func(*BindCollectionOptions)
- func Key(key string) func(*BindOptions)
- func NoViper(o *BindOptions)
- func ReadInConfig()
- func SelectField(name string) func(*BindCollectionOptions)
- func SelectValue(value string) func(*BindCollectionOptions)
- func Set(key string, value interface{})
- func Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error
- func UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
- func Write() error
- type BindCollectionOptions
- type BindOptions
Constants ¶
This section is empty.
Variables ¶
var ConfigLoader = func() { home, err := homedir.Dir() if err != nil { fmt.Println(err) os.Exit(1) } curDir, err := os.Getwd() if err != nil { fmt.Println(err) os.Exit(1) } exec, err := os.Executable() if err != nil { fmt.Println(err) os.Exit(1) } name := strings.TrimSuffix(filepath.Base(exec), (".exe")) viper.AddConfigPath(home) viper.AddConfigPath(".") viper.AddConfigPath(curDir) viper.SetConfigName("." + name) viper.AutomaticEnv() if err := viper.ReadInConfig(); err == nil { fmt.Println("Using config file:", viper.ConfigFileUsed()) } }
Functions ¶
func BindCollectionItem ¶
func BindCollectionItem(c *cobra.Command, rawVal interface{}, options ...func(*BindCollectionOptions))
func BindFlags ¶
func BindFlags(c *cobra.Command, rawVal interface{}, options ...func(*BindOptions))
BindCobraFlags binds a Struct with a viper config when running a Cobra command. Generates Cobra flags for the Struct so they can be overriden.
func BindFlagsKey ¶
BindCobraFlagsKey binds a Struct with a viper config at a specific key when running a Cobra command. Generates Cobra flags for the struct so they can be overriden
func BindPersistentFlags ¶
func BindPersistentFlags(c *cobra.Command, rawVal interface{}, options ...func(*BindOptions))
BindCobraPersistentFlags persistently binds a Struct with a viper config when running a Cobra command. Generates persistent flags for the struct so they can be overriden. Runs the parent persistent hooks as well.
func BindPersistentFlagsKey ¶
BindCobraFlagsKeyKey persistently binds a Struct with a viper config at a specific key when running a Cobra command. Generates persistent flags for the struct so they can be overriden
func BindTo ¶
func BindTo(rawVal interface{}) func(*BindCollectionOptions)
func Collection ¶
func Collection(collection *[]map[string]interface{}) func(*BindCollectionOptions)
func CollectionField ¶
func CollectionField(name string) func(*BindCollectionOptions)
func IdField ¶
func IdField(name string) func(*BindCollectionOptions)
func Key ¶
func Key(key string) func(*BindOptions)
func NoViper ¶
func NoViper(o *BindOptions)
func ReadInConfig ¶
func ReadInConfig()
func SelectField ¶
func SelectField(name string) func(*BindCollectionOptions)
func SelectValue ¶
func SelectValue(value string) func(*BindCollectionOptions)
func Unmarshal ¶
func Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error
Unmashal unmarshals the config into a Struct overriding with any flags that are set
func UnmarshalKey ¶
func UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
Unmashal takes a single key and unmarshals it into a Struct overriding with any flags that are set
Types ¶
type BindCollectionOptions ¶
type BindCollectionOptions struct {
// contains filtered or unexported fields
}
type BindOptions ¶
type BindOptions struct {
// contains filtered or unexported fields
}