Documentation
¶
Overview ¶
Package command provides command execution capabilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecParams ¶
type ExecParams struct {
// Command is the executable name or path.
Command string
// Args are the command arguments.
Args []string
// Cwd is the optional working directory.
Cwd string
// Timeout is the timeout in seconds (0 = default 30s).
Timeout int
}
ExecParams contains parameters for direct command execution.
type Executor ¶
type Executor struct {
provider.FactsAware
// contains filtered or unexported fields
}
Executor implements the Provider interface for command execution.
type Provider ¶
type Provider interface {
// Exec executes a command directly without a shell.
Exec(params ExecParams) (*Result, error)
// Shell executes a command through /bin/sh -c.
Shell(params ShellParams) (*Result, error)
}
Provider implements the methods to execute commands on the system.
type Result ¶
type Result struct {
// Stdout is the standard output.
Stdout string `json:"stdout"`
// Stderr is the standard error output.
Stderr string `json:"stderr"`
// ExitCode is the process exit code.
ExitCode int `json:"exit_code"`
// DurationMs is the execution time in milliseconds.
DurationMs int64 `json:"duration_ms"`
// Changed indicates whether the command modified system state.
Changed bool `json:"changed"`
}
Result contains the output of a command execution.
type ShellParams ¶
type ShellParams struct {
// Command is the full shell command string.
Command string
// Cwd is the optional working directory.
Cwd string
// Timeout is the timeout in seconds (0 = default 30s).
Timeout int
}
ShellParams contains parameters for shell command execution.
Click to show internal directories.
Click to hide internal directories.