Documentation
¶
Index ¶
- Constants
- func Cli() error
- func Configure() error
- func Env()
- func Reload() error
- func SetCommandOptions(c *cobra.Command, opts []*CommandOptions)
- func SetRootCommand(c *cobra.Command)
- func StatusTable(keys []string) string
- func UseConfigFile(name string) error
- type CommandOptions
- type Metadata
- type StatusError
- type StatusInfo
Constants ¶
const (
STATUS_NOT_FOUND = "not found"
)
Variables ¶
This section is empty.
Functions ¶
func Cli ¶
func Cli() error
Cli binds flags that have been configured as CommandOptions. Viper is the source of truth for all configuration. Cobra is only for reading in subcommands and cli flags and handling help display.
func Configure ¶
func Configure() error
Configure triggers the reading of the configuration from all sources.
func Reload ¶
func Reload() error
Reload discards any existing configuration and reloads from new sources
func SetCommandOptions ¶
func SetCommandOptions(c *cobra.Command, opts []*CommandOptions)
SetCommandOptions adds a cobra command with configuration options to the list for configuration by viper.
func SetRootCommand ¶
SetRootCommand allows panfigure access to the root cobra command from of an application.
func StatusTable ¶
StatusTable returns a text table, somewhat suitable for display in terminal, containing requested keys with values and sources.
func UseConfigFile ¶
Types ¶
type CommandOptions ¶
type CommandOptions struct {
LongOpt, ShortOpt, OptName, Description, OptType string
// NotImplemented is for options that have been begun aren't yet useful
NotImplemented,
NoCLI,
Persistent, Required bool
DefaultValue interface{}
}
CommandOptions are used to declare the configuration options for an application. They are most closely related to cobra.Command, but also define behavior for Env and file-based configs.
func (*CommandOptions) Name ¶
func (c *CommandOptions) Name() string
Name produces a name for the config value in Viper (and files) based on the LongOpt name, if a specific name is not provided.
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
Metadata is information that won't be used by the application, but might be interesting to the user, eg. through Status functions.
type StatusError ¶
type StatusError struct {
// contains filtered or unexported fields
}
func (*StatusError) Error ¶
func (s *StatusError) Error() string
type StatusInfo ¶
func Status ¶
func Status(keys []string) []*StatusInfo
Status returns StatusInfo for the requested keys. If an empty slice is passed, all Viper Keys will be returned.
func (*StatusInfo) String ¶
func (s *StatusInfo) String() string