Documentation
¶
Index ¶
- type Command
- func (c *Command) CaptureOutput() *Command
- func (c *Command) Kill() error
- func (c *Command) OnComplete(fn func(int)) *Command
- func (c *Command) OnError(fn func(error)) *Command
- func (c *Command) OnStderr(fn func(string)) *Command
- func (c *Command) OnStdout(fn func(string)) *Command
- func (c *Command) Run() error
- func (c *Command) RunAndStream() error
- func (c *Command) RunAsync() error
- func (c *Command) RunWithOutput() (*CommandResult, error)
- func (c *Command) StreamOutput() *Command
- func (c *Command) WithEnv(vars ...string) *Command
- func (c *Command) WithWorkingDir(dir string) *Command
- type CommandBuilder
- type CommandResult
- type CommandRunner
- type Platform
- type StreamHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a shell command to be executed
func (*Command) CaptureOutput ¶
CaptureOutput enables output capture for return
func (*Command) OnComplete ¶
OnComplete sets callback for completion
func (*Command) RunAndStream ¶
RunAndStream executes with real-time streaming
func (*Command) RunWithOutput ¶
func (c *Command) RunWithOutput() (*CommandResult, error)
RunWithOutput executes and captures output
func (*Command) StreamOutput ¶
StreamOutput enables real-time output streaming
func (*Command) WithWorkingDir ¶
WithWorkingDir sets the working directory
type CommandBuilder ¶
type CommandBuilder struct {
// contains filtered or unexported fields
}
CommandBuilder provides a fluent API for building commands
func NewCommandBuilder ¶
func NewCommandBuilder(platform *Platform) *CommandBuilder
NewCommandBuilder creates a new command builder
func (*CommandBuilder) New ¶
func (b *CommandBuilder) New(args ...string) *Command
New creates a command from arguments Example: New("npx", "prisma", "migrate", "dev")
func (*CommandBuilder) NewShell ¶
func (b *CommandBuilder) NewShell(ctx context.Context, cmdStr string) *Command
NewShell creates a command from a shell string Example: NewShell("npx prisma migrate dev --name init")
func (*CommandBuilder) NewWithContext ¶
func (b *CommandBuilder) NewWithContext(ctx context.Context, args ...string) *Command
NewWithContext creates a command with a context for cancellation
type CommandResult ¶
type CommandResult struct {
Stdout string
Stderr string
ExitCode int
Error error
Duration time.Duration
}
CommandResult holds the result of command execution
type CommandRunner ¶
type CommandRunner interface {
Run(cmd *Command) error
RunWithOutput(cmd *Command) (*CommandResult, error)
RunAsync(cmd *Command) error
RunAndStream(cmd *Command) error
}
CommandRunner interface for executing commands
type Platform ¶
Platform holds platform-specific configurations
func NewPlatform ¶
func NewPlatform() *Platform
NewPlatform creates a platform configuration for the current OS
type StreamHandler ¶
type StreamHandler struct {
// contains filtered or unexported fields
}
StreamHandler manages real-time output streaming with buffering
func NewStreamHandler ¶
func NewStreamHandler(onUpdate func(stdout, stderr []string)) *StreamHandler
NewStreamHandler creates a new stream handler
func (*StreamHandler) GetOutput ¶
func (h *StreamHandler) GetOutput() (stdout, stderr []string)
GetOutput returns the current buffered output
func (*StreamHandler) HandleStderr ¶
func (h *StreamHandler) HandleStderr(line string)
HandleStderr processes a stderr line
func (*StreamHandler) HandleStdout ¶
func (h *StreamHandler) HandleStdout(line string)
HandleStdout processes a stdout line