Documentation
¶
Overview ¶
Package executor is the core execution engine responsible for resolving variable dependencies, substituting values securely into shell commands, and dispatching those commands to the local shell environment or clipboard.
Index ¶
- func CollectDependencies(cheat *parser.Cheat, index *parser.CheatIndex) ([]string, map[string][]parser.VarDef)
- func CollectVarDefinitions(cheat *parser.Cheat, index *parser.CheatIndex) map[string][]parser.VarDef
- func EvaluateCondition(condition string, scope map[string]string) bool
- func FindAllDependencies(usedVars []string, varDefs map[string][]parser.VarDef) map[string]bool
- func FindAllVars(cmd string, syntax string) []string
- func ReplaceVar(cmd, varName, replacement string, syntax string) string
- func SubstituteVars(s string, scope map[string]string, syntax string) string
- func TopologicalSort(usedVars []string, varDefs map[string][]parser.VarDef, ...) []string
- type Clipboard
- type Executor
- func (e *Executor) BuildFinalCommand(cheat *parser.Cheat) string
- func (e *Executor) Execute(command string) error
- func (e *Executor) Index() *parser.CheatIndex
- func (e *Executor) Output(command string) error
- func (e *Executor) OutputWithMode(command string, mode OutputMode) error
- func (e *Executor) RunShell(command string) (string, error)
- func (e *Executor) Shell() string
- func (e *Executor) WithClipboard(c Clipboard) *Executor
- type OutputMode
- type ShellRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectDependencies ¶
func CollectDependencies(cheat *parser.Cheat, index *parser.CheatIndex) ([]string, map[string][]parser.VarDef)
CollectDependencies gathers all variable definitions and their topological ordering.
func CollectVarDefinitions ¶
func CollectVarDefinitions(cheat *parser.Cheat, index *parser.CheatIndex) map[string][]parser.VarDef
CollectVarDefinitions gathers all var definitions from imports and local cheat.
func EvaluateCondition ¶
EvaluateCondition evaluates a condition expression against the scope.
func FindAllDependencies ¶
FindAllDependencies finds transitive closure of all needed variables.
func FindAllVars ¶
FindAllVars finds ALL variable references in a command, ignoring quoting.
func ReplaceVar ¶
ReplaceVar replaces variable references in cmd with replacement.
func SubstituteVars ¶
SubstituteVars replaces variables in a string using the given scope. The syntax parameter controls which variable forms are replaced:
- "dollar": replaces $name
- "angle": replaces <name>
- "both": replaces both $name and <name>
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles shell command execution and variable substitution
func NewExecutor ¶
func NewExecutor(index *parser.CheatIndex) *Executor
NewExecutor creates a new executor with the given cheat index
func (*Executor) BuildFinalCommand ¶
BuildFinalCommand substitutes all variables in a cheat's command
func (*Executor) Index ¶
func (e *Executor) Index() *parser.CheatIndex
Index returns the cheat index
func (*Executor) OutputWithMode ¶
func (e *Executor) OutputWithMode(command string, mode OutputMode) error
OutputWithMode handles command output with an explicit mode
func (*Executor) WithClipboard ¶
WithClipboard sets a custom clipboard implementation (useful for testing)
type OutputMode ¶
type OutputMode string
OutputMode represents how the final command should be handled
const ( OutputPrint OutputMode = "print" OutputCopy OutputMode = "copy" OutputExec OutputMode = "exec" )