Documentation ¶
Overview ¶
Package cmd_config contains helper functions to support constructing Cobra commands, validating arguments and populating Viper config management
Index ¶
- Variables
- func BootstrapViper(loader *steampipeconfig.WorkspaceProfileLoader) error
- func DisplayConfig()
- func SetDefaultFromEnv(k string, configVar string, varType string)
- func SetDefaultsFromConfig(configMap map[string]interface{})
- func SetDefaultsFromEnv()
- func ValidateSnapshotArgs(ctx context.Context) error
- func Viper() *viper.Viper
- type CmdBuilder
- func (c *CmdBuilder) AddBoolFlag(name string, defaultValue bool, desc string, opts ...flagOpt) *CmdBuilder
- func (c *CmdBuilder) AddIntFlag(name string, defaultValue int, desc string, opts ...flagOpt) *CmdBuilder
- func (c *CmdBuilder) AddStringArrayFlag(name string, defaultValue []string, desc string, opts ...flagOpt) *CmdBuilder
- func (c *CmdBuilder) AddStringFlag(name string, defaultValue string, desc string, opts ...flagOpt) *CmdBuilder
- func (c *CmdBuilder) AddStringMapStringFlag(name string, defaultValue map[string]string, desc string, opts ...flagOpt) *CmdBuilder
- func (c *CmdBuilder) AddStringSliceFlag(name string, defaultValue []string, desc string, opts ...flagOpt) *CmdBuilder
Constants ¶
This section is empty.
Variables ¶
var FlagOptions = struct { Required func() flagOpt Hidden func() flagOpt Deprecated func(string) flagOpt NoOptDefVal func(string) flagOpt WithShortHand func(string) flagOpt }{ Required: requiredOpt, Hidden: hiddenOpt, Deprecated: deprecatedOpt, NoOptDefVal: noOptDefValOpt, WithShortHand: withShortHand, }
FlagOptions :: shortcut for common flag options
Functions ¶
func BootstrapViper ¶
func BootstrapViper(loader *steampipeconfig.WorkspaceProfileLoader) error
BootstrapViper sets up viper with the essential path config (workspace-chdir and install-dir)
func DisplayConfig ¶ added in v0.17.0
func DisplayConfig()
DisplayConfig prints all config set via WorkspaceProfile or HCL options
func SetDefaultFromEnv ¶ added in v0.17.0
func SetDefaultsFromConfig ¶ added in v0.17.0
func SetDefaultsFromConfig(configMap map[string]interface{})
SetDefaultsFromConfig overrides viper default values from hcl config values
func SetDefaultsFromEnv ¶ added in v0.19.0
func SetDefaultsFromEnv()
set default values from env vars
func ValidateSnapshotArgs ¶ added in v0.17.0
Types ¶
type CmdBuilder ¶
type CmdBuilder struct {
// contains filtered or unexported fields
}
func OnCmd ¶
func OnCmd(cmd *cobra.Command) *CmdBuilder
OnCmd starts a config builder wrapping over the provided *cobra.Command
func (*CmdBuilder) AddBoolFlag ¶
func (c *CmdBuilder) AddBoolFlag(name string, defaultValue bool, desc string, opts ...flagOpt) *CmdBuilder
AddBoolFlag ia s helper function to add a boolean flag to a command
func (*CmdBuilder) AddIntFlag ¶
func (c *CmdBuilder) AddIntFlag(name string, defaultValue int, desc string, opts ...flagOpt) *CmdBuilder
AddIntFlag is a helper function to add an integer flag to a command
func (*CmdBuilder) AddStringArrayFlag ¶
func (c *CmdBuilder) AddStringArrayFlag(name string, defaultValue []string, desc string, opts ...flagOpt) *CmdBuilder
AddStringArrayFlag is a helper function to add a flag that accepts an array of strings
func (*CmdBuilder) AddStringFlag ¶
func (c *CmdBuilder) AddStringFlag(name string, defaultValue string, desc string, opts ...flagOpt) *CmdBuilder
AddStringFlag is a helper function to add a string flag to a command
func (*CmdBuilder) AddStringMapStringFlag ¶
func (c *CmdBuilder) AddStringMapStringFlag(name string, defaultValue map[string]string, desc string, opts ...flagOpt) *CmdBuilder
AddStringMapStringFlag is a helper function to add a flag that accepts a map of strings
func (*CmdBuilder) AddStringSliceFlag ¶
func (c *CmdBuilder) AddStringSliceFlag(name string, defaultValue []string, desc string, opts ...flagOpt) *CmdBuilder
AddStringSliceFlag is a helper function to add a flag that accepts an array of strings