Documentation
¶
Index ¶
- func ParseAndRun(ctx context.Context, cmd cmds.Command, parseOptions []ParseOption, ...) error
- func ParseCommandValues(cmd cmds.Command, options ...ParseOption) (*values.Values, error)
- func RunCommand(ctx context.Context, cmd cmds.Command, parsedValues *values.Values, ...) error
- type ParseOption
- func WithAdditionalMiddlewares(middlewares ...cmd_sources.Middleware) ParseOption
- func WithConfigFiles(files ...string) ParseOption
- func WithEnvMiddleware(prefix string) ParseOption
- func WithEnvPrefix(prefix string) ParseOption
- func WithValuesForSections(values map[string]map[string]interface{}) ParseOption
- func WithViper() ParseOption
- type ParseOptions
- type RunOption
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAndRun ¶
func ParseAndRun( ctx context.Context, cmd cmds.Command, parseOptions []ParseOption, runOptions []RunOption, ) error
ParseAndRun combines value parsing and command execution into a single function.
func ParseCommandValues ¶ added in v1.0.0
ParseCommandValues parses values for a command using a configurable middleware chain.
Types ¶
type ParseOption ¶
type ParseOption func(*ParseOptions)
func WithAdditionalMiddlewares ¶
func WithAdditionalMiddlewares(middlewares ...cmd_sources.Middleware) ParseOption
WithAdditionalMiddlewares adds custom middlewares to the parsing chain
func WithConfigFiles ¶ added in v0.7.0
func WithConfigFiles(files ...string) ParseOption
WithConfigFiles applies a list of config files (low -> high precedence)
func WithEnvMiddleware ¶
func WithEnvMiddleware(prefix string) ParseOption
WithEnvMiddleware enables environment variable parsing with the given prefix
func WithEnvPrefix ¶
func WithEnvPrefix(prefix string) ParseOption
WithEnvPrefix sets the prefix for environment variable parsing
func WithValuesForSections ¶ added in v1.0.0
func WithValuesForSections(values map[string]map[string]interface{}) ParseOption
WithValuesForSections sets values for fields in specified sections.
func WithViper ¶
func WithViper() ParseOption
WithViper enables loading values from Viper configuration.
type ParseOptions ¶
type ParseOptions struct {
ValuesForSections map[string]map[string]interface{}
EnvPrefix string
AdditionalMiddlewares []cmd_sources.Middleware
UseViper bool
UseEnv bool
ConfigFiles []string
}
ParseOptions contains configuration for value parsing.
type RunOption ¶
type RunOption func(*RunOptions)
func WithGlazeProcessor ¶
func WithGlazeProcessor(p middlewares.Processor) RunOption
WithGlazeProcessor sets the processor to use for GlazeCommand output
func WithWriter ¶
WithWriter sets the writer to use for WriterCommand output
type RunOptions ¶
type RunOptions struct {
Writer io.Writer
GlazeProcessor middlewares.Processor
}
RunOptions contains configuration for running a command