cmdconfig

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CustomPostRunHook func(cmd *cobra.Command, args []string) error
View Source
var CustomPreRunHook func(cmd *cobra.Command, args []string) error
View Source
var FlagOptions = struct {
	Required      func() FlagOption
	Hidden        func() FlagOption
	Deprecated    func(string) FlagOption
	NoOptDefVal   func(string) FlagOption
	WithShortHand func(string) FlagOption
}{
	Required:      requiredOpt,
	Hidden:        hiddenOpt,
	Deprecated:    deprecatedOpt,
	NoOptDefVal:   noOptDefValOpt,
	WithShortHand: withShortHand,
}

FlagOptions shortcut for common flag options

Functions

func BootstrapViper

func BootstrapViper[T modconfig.WorkspaceProfile](loader *steampipeconfig.WorkspaceProfileLoader[T], cmd *cobra.Command, opts ...bootstrapOption)

BootstrapViper sets up viper with the essential path config (workspace-chdir and install-dir)

func GetConfigPath

func GetConfigPath() ([]string, error)

GetConfigPath builds a list of possible config file locations, starting with the HIGHEST priority

func GetWorkspaceProfileLoader

func GetWorkspaceProfileLoader[T modconfig.WorkspaceProfile]() (*steampipeconfig.WorkspaceProfileLoader[T], error)

GetWorkspaceProfileLoader creates a WorkspaceProfileLoader which loads the configured workspace

func SetConfigFromEnv

func SetConfigFromEnv(envVar string, configs []string, varType EnvVarType)

func SetDefaultFromEnv

func SetDefaultFromEnv(k string, configVar string, varType EnvVarType)

func SetDefaultsFromConfig

func SetDefaultsFromConfig(configMap map[string]any)

SetDefaultsFromConfig overrides viper default values from hcl config values

func SetDefaultsFromEnv

func SetDefaultsFromEnv(envMappings map[string]EnvMapping)

func Viper

func Viper() *viper.Viper

Viper fetches the global viper instance

func WithConfigDefaults

func WithConfigDefaults(configDefaults map[string]any) bootstrapOption

func WithDirectoryEnvMappings

func WithDirectoryEnvMappings(directoryEnvMappings map[string]EnvMapping) bootstrapOption

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 ...FlagOption) *CmdBuilder

AddBoolFlag ia s helper function to add a boolean flag to a command

func (*CmdBuilder) AddCloudFlags

func (c *CmdBuilder) AddCloudFlags() *CmdBuilder

AddCloudFlags is helper function to add the cloud flags to a command

func (*CmdBuilder) AddIntFlag

func (c *CmdBuilder) AddIntFlag(name string, defaultValue int, desc string, opts ...FlagOption) *CmdBuilder

AddIntFlag is a helper function to add an integer flag to a command

func (*CmdBuilder) AddModLocationFlag

func (c *CmdBuilder) AddModLocationFlag() *CmdBuilder

AddModLocationFlag is helper function to add the mod-location flag to a command

func (*CmdBuilder) AddPersistentBoolFlag

func (c *CmdBuilder) AddPersistentBoolFlag(name string, defaultValue bool, desc string) *CmdBuilder

AddPersistentBoolFlag ia s helper function to add a boolean flag to a command

func (*CmdBuilder) AddPersistentIntFlag

func (c *CmdBuilder) AddPersistentIntFlag(name string, defaultValue int, desc string) *CmdBuilder

AddPersistentIntFlag is a helper function to add an integer flag to a command

func (*CmdBuilder) AddPersistentStringArrayFlag

func (c *CmdBuilder) AddPersistentStringArrayFlag(name string, defaultValue []string, desc string) *CmdBuilder

AddPersistentStringArrayFlag is a helper function to add a flag that accepts an array of strings

func (*CmdBuilder) AddPersistentStringFlag

func (c *CmdBuilder) AddPersistentStringFlag(name string, defaultValue string, desc string) *CmdBuilder

AddPersistentStringFlag is a helper function to add a string flag to a command

func (*CmdBuilder) AddPersistentStringSliceFlag

func (c *CmdBuilder) AddPersistentStringSliceFlag(name string, defaultValue []string, desc string) *CmdBuilder

AddPersistentStringSliceFlag is a helper function to add a flag that accepts an array of strings

func (*CmdBuilder) AddPersistentVarFlag

func (c *CmdBuilder) AddPersistentVarFlag(value pflag.Value, name string, usage string) *CmdBuilder

func (*CmdBuilder) AddStringArrayFlag

func (c *CmdBuilder) AddStringArrayFlag(name string, defaultValue []string, desc string, opts ...FlagOption) *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 ...FlagOption) *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 ...FlagOption) *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 ...FlagOption) *CmdBuilder

AddStringSliceFlag is a helper function to add a flag that accepts an array of strings

func (*CmdBuilder) AddVarFlag added in v0.3.0

func (c *CmdBuilder) AddVarFlag(value pflag.Value, name string, usage string, opts ...FlagOption) *CmdBuilder

type EnvMapping

type EnvMapping struct {
	ConfigVar []string
	VarType   EnvVarType
}

type EnvVarType

type EnvVarType int
const (
	EnvVarTypeString EnvVarType = iota
	EnvVarTypeInt
	EnvVarTypeBool
)

func (EnvVarType) String

func (i EnvVarType) String() string

type FlagOption

type FlagOption func(c *cobra.Command, name string, key string)

Jump to

Keyboard shortcuts

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