Documentation ¶
Index ¶
- func IsFailedCondition(err error) bool
- func IsUnspecifiedClause(err error) bool
- type Arg
- type Args
- type Command
- type CommandList
- type Config
- type Context
- type Metadata
- type OptGetter
- type Option
- type Options
- type Run
- type RunList
- type SubTask
- type SubTaskList
- type Task
- type Value
- type ValueList
- type ValueWithList
- type When
- type WhenList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFailedCondition ¶
IsFailedCondition checks if an error was because of a failed condition.
func IsUnspecifiedClause ¶
IsUnspecifiedClause checks if an error was because a clause is not defined.
Types ¶
type Arg ¶
type Arg struct { ValueWithList `yaml:",inline"` Usage string // Computed members not specified in yaml file Name string `yaml:"-"` Passed string `yaml:"-"` }
Arg represents a command-line argument.
type Args ¶
type Args []*Arg
Args represents an ordered set of arguments as specified in the config.
func (*Args) UnmarshalYAML ¶
UnmarshalYAML unmarshals an ordered set of options and assigns names.
type Command ¶
type Command struct { // Exec is the script to execute. Exec string `yaml:"exec"` // Print is the text that will be printed when the command is executed. Print string `yaml:"print"` // Quiet means that no text/hint will be printed before execution. Command // output is still printed, similar to '--quiet' flag. Quiet bool `yaml:"quiet,omitempty"` // Dir is the directory of the command. Dir string `yaml:"dir"` }
Command is a command passed to the shell.
func (*Command) UnmarshalYAML ¶
UnmarshalYAML allows strings to be interpreted as Do actions.
type CommandList ¶
type CommandList []Command
CommandList is a list of commands with custom yaml unamrshaling.
func (*CommandList) UnmarshalYAML ¶
func (cl *CommandList) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML allows single items to be used as lists.
type Config ¶
type Config struct { Name string `yaml:"name"` Usage string `yaml:"usage"` // The Interpreter field must be read before the config struct can be parsed // completely from YAML. To do so, the config text parses it elsewhere in the // code base independently from this struct. // // It is included here only so that strict unmarshaling does not fail. Interpreter string `yaml:"interpreter"` Tasks map[string]*Task `yaml:"tasks"` Options Options `yaml:"options,omitempty"` }
Config is a struct representing the format for configuration settings.
func ParseComplete ¶
func ParseComplete( meta *Metadata, taskName string, args []string, flags map[string]string, ) (*Config, error)
ParseComplete parses the file completely with interpolation.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML unmarshals and assigns names to options and tasks.
type Context ¶ added in v0.6.0
type Context struct { // Logger is responsible for logging actions as they occur. It is required to // be defined for a Context. Logger *ui.Logger // Interpreter specifies how a command is meant to be executed. Interpreter []string // contains filtered or unexported fields }
Context contains contextual information about a run.
type Metadata ¶
type Metadata struct { CfgText []byte Interpreter []string Directory string InstallCompletion string UninstallCompletion string PrintHelp bool PrintVersion bool Logger *ui.Logger }
Metadata contains global configuration settings.
Metadata should be instantiated using NewMetadata.
func NewMetadata ¶ added in v0.6.0
func NewMetadata() *Metadata
NewMetadata creates a metadata struct with a default logger.
type OptGetter ¶
OptGetter pulls various options based on a name. These options will generally come from the command line.
type Option ¶
type Option struct { ValueWithList `yaml:",inline"` Short string Type string Usage string Private bool Required bool // Used to determine value Environment string DefaultValues ValueList `yaml:"default"` // Computed members not specified in yaml file Name string `yaml:"-"` Passed string `yaml:"-"` // contains filtered or unexported fields }
Option represents an abstract command line option.
func FindAllOptions ¶
FindAllOptions returns a list of options relevant for a given config.
func (*Option) Dependencies ¶
Dependencies returns a list of options that are required explicitly. This does not include interpolations.
func (*Option) Evaluate ¶
Evaluate determines an option's value.
The order of priority is:
- Command-line option passed
- Environment variable set
- The first item in the default value list with a valid when clause
Values may also be cached to avoid re-running commands.
func (*Option) UnmarshalYAML ¶
UnmarshalYAML ensures that the option definition is valid.
type Options ¶
type Options []*Option
Options represents an ordered set of options as specified in the config.
func (*Options) UnmarshalYAML ¶
UnmarshalYAML unmarshals an ordered set of options and assigns names.
type Run ¶
type Run struct { When WhenList `yaml:",omitempty"` Command CommandList `yaml:",omitempty"` SubTaskList SubTaskList `yaml:"task,omitempty"` SetEnvironment map[string]*string `yaml:"set-environment,omitempty"` // Computed members not specified in yaml file Tasks []Task `yaml:"-"` }
Run defines a a single runnable item within a task.
func (*Run) UnmarshalYAML ¶
UnmarshalYAML allows simple commands to represent run structs.
type RunList ¶
type RunList []*Run
RunList is a list of run items with custom yaml unmarshaling.
func (*RunList) UnmarshalYAML ¶
UnmarshalYAML allows single items to be used as lists.
type SubTask ¶
type SubTask struct { Name string Args marshal.StringList Options map[string]string }
SubTask is a description of a sub-task with passed options.
func (*SubTask) UnmarshalYAML ¶
UnmarshalYAML allows unmarshaling a string to represent the subtask name.
type SubTaskList ¶
type SubTaskList []*SubTask
SubTaskList is a list of subtasks with custom yaml unmarshaling.
func (*SubTaskList) UnmarshalYAML ¶
func (l *SubTaskList) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML allows single items to be used as lists.
type Task ¶
type Task struct { Args Args `yaml:"args,omitempty"` Options Options `yaml:"options,omitempty"` RunList RunList `yaml:"run"` Finally RunList `yaml:"finally,omitempty"` Usage string `yaml:",omitempty"` Description string `yaml:",omitempty"` Private bool Quiet bool // Computed members not specified in yaml file Name string `yaml:"-"` Vars map[string]string `yaml:"-"` }
Task is a single task to be run by CLI.
func (*Task) AllRunItems ¶
AllRunItems returns all run items referenced, including `run` and `finally`.
func (*Task) Dependencies ¶
Dependencies returns a list of options that are required explicitly. This does not include interpolations.
func (*Task) UnmarshalYAML ¶
UnmarshalYAML unmarshals and assigns names to options.
type Value ¶
Value represents a value candidate for an option. When the when condition is true, either the command or value will be used.
func (*Value) UnmarshalYAML ¶
UnmarshalYAML allows plain strings to represent a full struct. The value of the string is used as the Default field.
type ValueList ¶
type ValueList []Value
ValueList is a slice of values with custom unmarshaling.
func (*ValueList) UnmarshalYAML ¶
UnmarshalYAML allows single items to be used as lists.
type ValueWithList ¶
type ValueWithList struct {
ValuesAllowed marshal.StringList `yaml:"values"`
}
ValueWithList is a list of allowable values for an option or argument.
type When ¶
type When struct { Command marshal.StringList `yaml:",omitempty"` Exists marshal.StringList `yaml:",omitempty"` NotExists marshal.StringList `yaml:"not-exists,omitempty"` OS marshal.StringList `yaml:",omitempty"` Environment map[string]marshal.NullableStringList `yaml:",omitempty"` Equal map[string]marshal.StringList `yaml:",omitempty"` NotEqual map[string]marshal.StringList `yaml:"not-equal,omitempty"` }
When defines the conditions for running a task.
func (*When) Dependencies ¶
Dependencies returns a list of options that are required explicitly. This does not include interpolations.
func (*When) UnmarshalYAML ¶
UnmarshalYAML warns about deprecated features.
type WhenList ¶
type WhenList []When
WhenList is a list of when items with custom yaml unmarshaling.
func (*WhenList) Dependencies ¶
Dependencies returns a list of options that are required explicitly. This does not include interpolations.
func (*WhenList) UnmarshalYAML ¶
UnmarshalYAML allows single items to be used as lists.