cobrautil

package module
v0.0.0-...-6f87e0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindConfig

func BindConfig(cfg interface{}, cmd *cobra.Command, opt ...Option) error

BindConfig creates cobra flags based on cfg, which must be a pointer to a configuration struct. Struct is then populated from flags -> env variables -> configuration file in this order. Configuration file must be named as the cmd name with one of the extensions supported by viper.

Types

type Option

type Option func(*options)

Option is a type for options.

func WithStrict

func WithStrict(enable bool) Option

WithStrict enables the strict mode for configuration binding. This means that binding will fail if specified configuration file doesn't exist.

func WithViper

func WithViper(v *viper.Viper) Option

WithViper providers a custom Viper instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL