Documentation
¶
Overview ¶
Package command implements both rules and profiles, providing a single API for command execution, file watching, and event handling.
Index ¶
- Variables
- type Config
- 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) SetExtraArgs(args []string) error
- 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 (
DefaultConfig = MustNewConfig(defaultProfiles, defaultRules)
)
var ErrNoCommandForPath = errors.New("no command for path")
ErrNoCommandForPath is returned when no command is found for a path.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Profiles contains a map of profile names to profile configurations.
Profiles map[string]*profile.Profile `json:"profiles,omitempty" jsonschema:"title=Profiles"`
// Rules defines the rules for matching files to profiles.
Rules []*rule.Rule `json:"rules,omitempty" jsonschema:"title=Rules"`
}
Config defines the core (non-UI) kat configuration.
func (*Config) EnsureDefaults ¶
func (c *Config) EnsureDefaults()
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.
func (*Runner) SetExtraArgs ¶ added in v0.21.0
type RunnerOpt ¶
func WithProfile ¶
WithProfile sets a specific profile to use.
type Static ¶
func (*Static) GetCurrentProfile ¶
func (*Static) RunOnEvent ¶
func (rg *Static) RunOnEvent()