Documentation ¶
Index ¶
- Constants
- func NewInvalidParameterSpecError(reason string) error
- type Parameter
- type ParameterSet
- func (ps ParameterSet) CreateCLIFlags() []cli.Flag
- func (ps ParameterSet) InjectValues(str string) string
- func (ps ParameterSet) Optional() ParameterSet
- func (ps ParameterSet) Required() ParameterSet
- func (ps ParameterSet) ResolveValues(ctx *cli.Context) error
- func (ps ParameterSet) Validate() error
- type Provider
Constants ¶
const ( // BoolParamType is a bool parameter. BoolParamType = "bool" // IntParamType is an int parameter. IntParamType = "int" // NumberParamType is a number parameter. NumberParamType = "number" // StringParamType is a string parameter. StringParamType = "string" )
Variables ¶
This section is empty.
Functions ¶
func NewInvalidParameterSpecError ¶ added in v0.2.0
NewInvalidParameterSpecError creates a new error indicating that a parameter spec is invalid.
Types ¶
type Parameter ¶ added in v0.2.0
type Parameter struct { Name string `json:"name" yaml:"name"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Type string `json:"type" yaml:"type"` Required bool `json:"required" yaml:"required"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` AsFlag string `json:"as_flag,omitempty" yaml:"as_flag,omitempty"` // contains filtered or unexported fields }
A Parameter specifies a command parameter.
func NewParameter ¶ added in v0.2.0
NewParameter creates a new Parameter from the provided spec.
func (*Parameter) CLIFlagName ¶ added in v0.2.0
CLIFlagName returns the parameter name formatted as a CLI flag name.
func (*Parameter) CreateCLIFlag ¶ added in v0.2.0
func (param *Parameter) CreateCLIFlag() cli.Flag
CreateCLIFlag creates a CLI flag for this parameter.
func (*Parameter) SetDefaultValue ¶ added in v0.2.0
func (param *Parameter) SetDefaultValue()
SetDefaultValue assigns the default value to the parameter.
func (*Parameter) SetValue ¶ added in v0.2.0
func (param *Parameter) SetValue(value interface{})
SetValue assigns a value to the parameter.
type ParameterSet ¶ added in v0.2.0
type ParameterSet []*Parameter
A ParameterSet is a slice of parameter pointers.
func (ParameterSet) CreateCLIFlags ¶ added in v0.2.0
func (ps ParameterSet) CreateCLIFlags() []cli.Flag
CreateCLIFlags creates a set of CLI flags for this parameter set.
func (ParameterSet) InjectValues ¶ added in v0.2.0
func (ps ParameterSet) InjectValues(str string) string
InjectValues replaces all param references with their corresponding values in the given string.
func (ParameterSet) Optional ¶ added in v0.2.0
func (ps ParameterSet) Optional() ParameterSet
Optional returns a subset of the ParameterSet containing only optional parameters.
func (ParameterSet) Required ¶ added in v0.2.0
func (ps ParameterSet) Required() ParameterSet
Required returns a subset of the ParameterSet containing only required parameters.
func (ParameterSet) ResolveValues ¶ added in v0.2.0
func (ps ParameterSet) ResolveValues(ctx *cli.Context) error
ResolveValues assigns values to the parameters from defaults and the CLI context.
func (ParameterSet) Validate ¶ added in v0.2.0
func (ps ParameterSet) Validate() error
Validate validates the parameter set, returning the first error it encounters, if any.