Documentation
¶
Index ¶
- Variables
- type Config
- type ConfigError
- type Event
- type EventCancel
- type EventEnd
- type EventStart
- type Output
- type Runner
- func (cr *Runner) Close()
- func (cr *Runner) GetCurrentProfile() *profile.Profile
- func (cr *Runner) Run() Output
- func (cr *Runner) RunContext(ctx context.Context) Output
- func (cr *Runner) RunOnEvent()
- func (cr *Runner) RunPlugin(name string) Output
- func (cr *Runner) RunPluginContext(ctx context.Context, name string) Output
- func (cr *Runner) String() string
- func (cr *Runner) Subscribe(ch chan<- Event)
- func (cr *Runner) Watch() error
- type RunnerOpt
- type Static
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoCommandForPath is returned when no command is found for a path. ErrNoCommandForPath = errors.New("no command for path") // ErrCommandExecution is returned when command execution fails. ErrCommandExecution = errors.New("command execution") // ErrEmptyCommand is returned when a command is empty. ErrEmptyCommand = errors.New("empty command") // ErrHookExecution is returned when hook execution fails. ErrHookExecution = errors.New("hook execution") )
var (
DefaultConfig = MustNewConfig(defaultProfiles, defaultRules)
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Profiles map[string]*profile.Profile `validate:"dive" yaml:"profiles,omitempty"`
Rules []*rule.Rule `validate:"dive" yaml:"rules,omitempty"`
}
func (*Config) EnsureDefaults ¶
func (c *Config) EnsureDefaults()
func (*Config) Validate ¶
func (c *Config) Validate() *ConfigError
type ConfigError ¶
func (ConfigError) Error ¶
func (e ConfigError) Error() string
type EventCancel ¶
type EventCancel struct{}
EventCancel indicates that a command execution has been canceled.
type EventEnd ¶
type EventEnd Output
EventEnd indicates that a command execution has ended. This event carries the output of the command execution, which could be an error if the command failed.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner wraps one or more Rule objects. It manages:
- File-to-command mappings.
- Filesystem notifications / watching.
- Concurrent command execution.
func (*Runner) GetCurrentProfile ¶
func (*Runner) Run ¶
RunFirstMatch executes the first matching command for the given path. If path is a file, it checks for direct matches. If path is a directory, it checks all files in the directory for matches.
func (*Runner) RunContext ¶
RunContext executes the first matching command for the given path with the provided context. If path is a file, it checks for direct matches. If path is a directory, it checks all files in the directory for matches. The context can be used for cancellation, timeouts, and tracing.
func (*Runner) RunOnEvent ¶
func (cr *Runner) RunOnEvent()
RunOnEvent listens for file system events and runs the command in response. The output should be collected via Runner.Subscribe.
func (*Runner) RunPluginContext ¶
RunPluginContext executes a plugin by name with the provided context.
type RunnerOpt ¶
func WithProfile ¶
WithProfile sets a specific profile to use.
type Static ¶
func (*Static) GetCurrentProfile ¶
func (*Static) RunOnEvent ¶
func (rg *Static) RunOnEvent()