Documentation
¶
Index ¶
- func CleanCache() error
- func CleanProjectCache(cfgPath string) error
- func CleanTaskCache(cfgPath string, task string) error
- func IsFailedCondition(err error) bool
- func IsUnspecifiedClause(err error) bool
- type Arg
- type Args
- type Command
- type Config
- type Context
- type EnvFile
- type Option
- type Options
- type ParseConfig
- type Passable
- type Run
- type SubTask
- type Task
- type Value
- type When
- type WhenList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanProjectCache ¶ added in v0.8.0
CleanProjectCache deletes cached files related to the current config file.
func CleanTaskCache ¶ added in v0.8.0
CleanTaskCache deletes cached files related to the given task.
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 Args ¶
type Args []*Arg
Args represents an ordered set of arguments as specified in the config.
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.
type Config ¶
type Config struct {
Name string `yaml:"name"`
Usage string `yaml:"usage"`
EnvFile marshal.Slice[EnvFile] `yaml:"env-file"`
// 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 *ParseConfig) (*Config, error)
ParseComplete parses the file completely with env file parsing and interpolation.
type Context ¶ added in v0.6.0
type Context struct {
// CfgPath is the full path of the configuration file.
CfgPath string
// 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.
func (Context) Dir ¶ added in v0.7.0
Dir is the directory that defines the config file, which is the relative directory for all command execution.
type EnvFile ¶ added in v0.7.0
EnvFile is a dotenv file that should be parsed during configuration start.
type Option ¶
type Option struct {
Passable `yaml:",inline"`
Short string
Private bool
Required bool
Rewrite string
// Used to determine value
Environment string
DefaultValues marshal.Slice[Value] `yaml:"default"`
// 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) Equal ¶ added in v0.7.0
Equal provides a method of checking option equality for testing purposes only.
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) StaticDefault ¶ added in v0.7.2
StaticDefault returns the default value, if static.
type Options ¶
type Options []*Option
Options represents an ordered set of options as specified in the config.
type ParseConfig ¶ added in v0.8.0
type ParseConfig struct {
Args []string
CfgPath string
CfgText []byte
Flags map[string]string
Interpreter []string
TaskName string
}
ParseConfig is the configuration for parsing the configuration file.
type Passable ¶ added in v0.7.0
type Passable struct {
Usage string `yaml:"usage"`
Type string `yaml:"type"`
ValuesAllowed marshal.Slice[string] `yaml:"values"`
// Computed members not specified in yaml file
Name string `yaml:"-"`
Passed string `yaml:"-"`
}
Passable is a list of allowable values for an option or argument.
type Run ¶
type Run struct {
When WhenList `yaml:",omitempty"`
Command marshal.Slice[*Command] `yaml:",omitempty"`
SubTaskList marshal.Slice[*SubTask] `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.
type Task ¶
type Task struct {
Args Args `yaml:"args,omitempty"`
Options Options `yaml:"options,omitempty"`
RunList marshal.Slice[*Run] `yaml:"run"`
Finally marshal.Slice[*Run] `yaml:"finally,omitempty"`
Usage string `yaml:"usage,omitempty"`
Description string `yaml:"description,omitempty"`
Private bool `yaml:"private"`
Quiet bool `yaml:"quiet"`
Source marshal.Slice[string] `yaml:"source"`
Target marshal.Slice[string] `yaml:"target"`
// 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.
type Value ¶
Value represents a value candidate for an option. When the when condition is true, either the command or value will be used.
type When ¶
type When struct {
Command marshal.Slice[string] `yaml:",omitempty"`
Exists marshal.Slice[string] `yaml:",omitempty"`
NotExists marshal.Slice[string] `yaml:"not-exists,omitempty"`
OS marshal.Slice[string] `yaml:",omitempty"`
Environment map[string]marshal.Slice[*string] `yaml:",omitempty"`
Equal map[string]marshal.Slice[string] `yaml:",omitempty"`
NotEqual map[string]marshal.Slice[string] `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 ¶
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.