Documentation ¶
Index ¶
- Constants
- func CmdRunBegin(v *viper.Viper)
- func Compress(in []byte) []byte
- func CopyMissingValues(src, dst interface{})
- func DeCompress(in []byte) []byte
- func FileExists(name string) bool
- func FlagString(v *viper.Viper, flags *pflag.FlagSet, name, short string, def string, ...)
- func GetDefaultConfigFile(cmdName string) string
- func Marshal(from interface{}, what string) ([]byte, error)
- func ParseObj(obj interface{}, cb func(*Field) error, tags map[string]string) error
- func RegisterFlags(v *viper.Viper, flags *pflag.FlagSet, config interface{}, ...) error
- func RsaSignWithSha256(data []byte, keyBytes []byte) []byte
- func RsaVerySignWithSha256(data, signData, keyBytes []byte) bool
- func Unmarshal(from []byte, to interface{}, what string) error
- func ValidateAndReturnAbsConf(configFilePath, homeDir, cmdName string) (string, string, error)
- func ViperUnmarshal(cfg interface{}, stringSliceFields []string, vp *viper.Viper) error
- type Field
Constants ¶
const ( // TagDefault is the tag name for a default value of a field as recognized // by RegisterFlags. TagDefault = "def" // TagHelp is the tag name for a help message of a field as recognized // by RegisterFlags. TagHelp = "help" // TagOpt is the tag name for a one character option of a field as recognized // by RegisterFlags. For example, a value of "d" reserves "-d" for the // command line argument. TagOpt = "opt" // TagSkip is the tag name which causes the field to be skipped by // RegisterFlags. TagSkip = "skip" // TagHide is the tag name which causes the field to be hidden TagHide = "hide" )
Variables ¶
This section is empty.
Functions ¶
func CmdRunBegin ¶
CmdRunBegin is called at the beginning of each cobra run function
func CopyMissingValues ¶
func CopyMissingValues(src, dst interface{})
CopyMissingValues checks the dst interface for missing values and replaces them with value from src config struct. This does a deep copy of pointers.
func FileExists ¶
func FlagString ¶
FlagString sets up a flag for a string, binding it to its name
func GetDefaultConfigFile ¶
func RegisterFlags ¶
func RegisterFlags(v *viper.Viper, flags *pflag.FlagSet, config interface{}, tags map[string]string) error
RegisterFlags registers flags for all fields in an arbitrary 'config' object. This method recognizes the following field tags: "def" - the default value of the field; "opt" - the optional one character short name to use on the command line; "help" - the help message to display on the command line; "skip" - to skip the field.
func ViperUnmarshal ¶
ViperUnmarshal is a work around for a bug in viper.Unmarshal This can be removed once https://github.com/spf13/viper/issues/327 is fixed and vendored.