Documentation
¶
Overview ¶
Package shell provides audited command execution for lore.
Commands are executed through bash, so pipes, redirects, loops, and variable expansion work exactly as expected. Go orchestrates and audits; bash does the work.
sh := shell.New()
sh.Run("brew install kubectl")
sh.Run("kubectl version --client")
sh.Run("echo $PATH | tr ':' '\\n' | head -5")
Index ¶
- type Result
- type Session
- func (s *Session) Audit(w io.Writer) *Session
- func (s *Session) Dir(path string) *Session
- func (s *Session) History() []*Result
- func (s *Session) Must(command string) *Result
- func (s *Session) Run(command string) *Result
- func (s *Session) RunContext(ctx context.Context, command string) *Result
- func (s *Session) Script(commands ...string) *Result
- func (s *Session) Set(key, value string) *Session
- func (s *Session) With(key, value string) *Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Command string `json:"command"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
ExitCode int `json:"exit_code"`
Start time.Time `json:"start"`
Duration time.Duration `json:"duration"`
Error string `json:"error,omitempty"`
}
Result captures everything about a command execution.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is an audited shell session.
func (*Session) Run ¶
Run executes a command through bash. Pipes, redirects, loops, and variable expansion work as expected.
func (*Session) RunContext ¶
RunContext executes a command with a context for cancellation/timeout.
func (*Session) Script ¶
Script runs multiple commands in sequence, stopping on first failure. Returns the failing result, or the last successful result.
Click to show internal directories.
Click to hide internal directories.