Documentation
¶
Overview ¶
Package cli implements the Road Runner command-line interface.
The package is organized around Cobra commands, with each command delegating to workflow functions for the actual work. The general structure follows a clean separation between:
- Command definitions (cobra.Command instances)
- Workflow orchestration (SetupWorkflow, connect/sync/lock phases)
- Implementation details (in other internal packages)
Command Structure ¶
The root command is "rr" with subcommands for different operations:
rr run [command] - Sync code and execute remotely rr exec [command] - Execute without syncing rr sync - Sync files only rr init - Create .rr.yaml config rr setup <host> - Configure SSH keys rr host [add|remove|list] - Manage hosts rr monitor - Real-time metrics dashboard rr doctor - Diagnose issues
Workflow System ¶
The SetupWorkflow function handles the common phases shared by run/exec/sync:
- Load and validate config
- Select and connect to a host (with fallback)
- Sync files (optional, skipped for exec)
- Acquire lock (if enabled)
Commands use WorkflowContext to carry state through these phases, then execute their specific logic. The context must be closed to release resources like locks and connections.
Flag Handling ¶
Global flags (--config, --verbose, --quiet, --no-color) are defined on the root command and available to all subcommands. Command-specific flags like --host and --tag are defined on individual commands.
The CommonFlags type and AddCommonFlags function provide a standard way to add host selection flags (--host, --tag, --probe-timeout) to commands.
Task Registration ¶
Named tasks from the config file are registered as first-class commands during startup. This allows "rr mytask" to work like "rr run" with the task's configured command. Tasks are registered before Cobra parses flags, using a pre-scan of os.Args for --config.
Input Validation ¶
User input comes from three sources, each with its own validation:
1. Command-line flags (validated by Cobra and ParseProbeTimeout):
- --host: String, used as map key in config.Hosts (validated at selection)
- --tag: String, matched against host tags (validated at selection)
- --probe-timeout: Duration string parsed by time.ParseDuration
- --config: File path, validated by config.Find/Load
2. Command arguments (validated in command handlers):
- Commands to execute (run, exec): Joined and passed to remote shell The remote shell handles parsing; no local sanitization needed since the user controls both ends. Shell metacharacters work as expected.
3. Config file (.rr.yaml) (validated by config.Validate):
- Host SSH strings: Must not be empty
- Host directories: Validated for unexpanded variables; ~ allowed for remote
- Shell format: Must end with a flag like -c
- Task names: Must not conflict with built-in commands
- Task steps: Must have run commands, valid on_fail values
- Output/lock/monitor: Validated against allowed values
Security notes:
- Commands are executed via SSH as the authenticated user - they're not sanitized because the user has shell access anyway
- Config paths use os.Getwd() and filepath operations - path traversal attempts would require modifying the config file, which already implies write access to the project
- SSH connections use the system SSH agent or configured keys - no credential storage in the tool itself
Index ¶
- Constants
- func AddCommonFlags(cmd *cobra.Command, flags *CommonFlags)
- func Config() string
- func Execute()
- func ExecutePullPhase(wf *WorkflowContext, pullItems []config.PullItem, dest string)
- func ExpandLogsDir(dir string) string
- func FormatParallelTaskHelp(task *config.TaskConfig, cfg *config.Config) string
- func GetGlobalLogsConfig() config.LogsConfig
- func GetRootCmd() *cobra.Command
- func GetVersion() string
- func Init(opts InitOptions) error
- func ListTasks() error
- func MachineMode() bool
- func NoColor() bool
- func ParseProbeTimeout(flag string) (time.Duration, error)
- func PrettyMode() bool
- func PrintParallelHelp()
- func Pull(opts PullOptions) error
- func Quiet() bool
- func RefreshUpdateCache()
- func RegisterTaskCommands(cfg *config.Config)
- func Run(opts RunOptions) (int, error)
- func RunParallelTask(opts ParallelTaskOptions) (int, error)
- func RunTask(opts TaskOptions) (int, error)
- func SetVersionInfo(v, c, d string)
- func Setup(opts SetupOptions) error
- func Sync(opts SyncOptions) error
- func Update(opts UpdateOptions) error
- func ValidateLocalAndTag(local bool, tag string) error
- func Verbose() bool
- func WriteJSONError(w io.Writer, code, message, suggestion string, details interface{}) error
- func WriteJSONFromError(w io.Writer, err error) error
- func WriteJSONSuccess(w io.Writer, data interface{}) error
- func WritePhaseEvent(event PhaseEvent)
- type AliasStatus
- type CategoryOutput
- type CommonFlags
- type DoctorOutput
- type FixOption
- type FixResult
- type HostAddOptions
- type HostConfigInfo
- type HostListOutput
- type HostStatus
- type InitOptions
- type JSONEnvelope
- type JSONError
- type ParallelTaskOptions
- type PhaseEvent
- type PhaseReporter
- type PrettyReporter
- func (r *PrettyReporter) CommandComplete(exitCode int, host string, totalDuration, execDuration time.Duration)
- func (r *PrettyReporter) CommandPrompt(command string)
- func (r *PrettyReporter) Divider()
- func (r *PrettyReporter) PhaseComplete(phase, host string, duration time.Duration)
- func (r *PrettyReporter) PhaseFailed(phase string, err error)
- func (r *PrettyReporter) PhaseSkipped(phase, reason string)
- func (r *PrettyReporter) PhaseStart(phase string)
- func (r *PrettyReporter) ThinDivider()
- type ProvisionHostResult
- type ProvisionOptions
- type ProvisionOutput
- type ProvisionRequirementItem
- type ProvisionSummary
- type PullOptions
- type RunOptions
- type Selected
- type SetupOptions
- type StatusOutput
- type StructuredReporter
- func (r *StructuredReporter) CommandComplete(exitCode int, host string, totalDuration, execDuration time.Duration)
- func (r *StructuredReporter) CommandPrompt(command string)
- func (r *StructuredReporter) Divider()
- func (r *StructuredReporter) PhaseComplete(phase, host string, duration time.Duration)
- func (r *StructuredReporter) PhaseFailed(phase string, err error)
- func (r *StructuredReporter) PhaseSkipped(phase, reason string)
- func (r *StructuredReporter) PhaseStart(phase string)
- func (r *StructuredReporter) ThinDivider()
- type SummaryOutput
- type SyncOptions
- type TaskInfo
- type TaskOptions
- type TasksOutput
- type UnlockOptions
- type UpdateOptions
- type WorkflowContext
- type WorkflowOptions
Constants ¶
const ( ErrCodeConfigNotFound = "CONFIG_NOT_FOUND" ErrCodeConfigInvalid = "CONFIG_INVALID" ErrCodeHostNotFound = "HOST_NOT_FOUND" ErrCodeSSHTimeout = "SSH_TIMEOUT" ErrCodeSSHAuthFailed = "SSH_AUTH_FAILED" ErrCodeSSHHostKey = "SSH_HOST_KEY" ErrCodeSSHConnectionFail = "SSH_CONNECTION_FAILED" ErrCodeRsyncFailed = "RSYNC_FAILED" ErrCodeLockHeld = "LOCK_HELD" ErrCodeCommandFailed = "COMMAND_FAILED" ErrCodeDependencyMissing = "DEPENDENCY_MISSING" ErrCodeUnknown = "UNKNOWN" )
Error codes for machine-readable output. These map to specific actions an LLM/automation can take.
Variables ¶
This section is empty.
Functions ¶
func AddCommonFlags ¶ added in v0.4.0
func AddCommonFlags(cmd *cobra.Command, flags *CommonFlags)
AddCommonFlags registers --host, --tag, --probe-timeout, and --local flags on a command.
func Execute ¶
func Execute()
Execute runs the root command and handles errors with structured output.
func ExecutePullPhase ¶ added in v0.19.0
func ExecutePullPhase(wf *WorkflowContext, pullItems []config.PullItem, dest string)
ExecutePullPhase downloads files from remote after command execution. Pull happens regardless of command exit code - often you want test artifacts on failure. Errors are logged but don't fail the overall workflow.
func ExpandLogsDir ¶ added in v0.11.0
ExpandLogsDir expands ~ in a logs directory path.
func FormatParallelTaskHelp ¶ added in v0.11.0
func FormatParallelTaskHelp(task *config.TaskConfig, cfg *config.Config) string
FormatParallelTaskHelp returns a formatted description for parallel task help.
func GetGlobalLogsConfig ¶ added in v0.11.0
func GetGlobalLogsConfig() config.LogsConfig
GetGlobalLogsConfig returns the logs config from global config for CLI commands.
func GetRootCmd ¶
GetRootCmd returns the root command for testing and subcommand registration.
func Init ¶
func Init(opts InitOptions) error
Init creates a new .rr.yaml project configuration file.
func ListTasks ¶ added in v0.8.0
func ListTasks() error
ListTasks displays all available tasks from the configuration.
func MachineMode ¶ added in v0.11.7
func MachineMode() bool
MachineMode returns true if machine-readable output is enabled. With structured output as default, this is always true unless --pretty is set.
func ParseProbeTimeout ¶ added in v0.4.0
ParseProbeTimeout parses a probe timeout string into a duration. Returns zero duration if the flag is empty.
func PrettyMode ¶ added in v0.21.0
func PrettyMode() bool
PrettyMode returns true if pretty (human-readable) output is enabled
func PrintParallelHelp ¶ added in v0.11.0
func PrintParallelHelp()
PrintParallelHelp prints help text specific to parallel task execution.
func Pull ¶ added in v0.19.0
func Pull(opts PullOptions) error
Pull downloads files from the remote host to the local machine.
func RefreshUpdateCache ¶
func RefreshUpdateCache()
RefreshUpdateCache forces a refresh of the update cache in the background This can be called during other operations to keep the cache fresh
func RegisterTaskCommands ¶
RegisterTaskCommands dynamically registers task commands from config. This should be called after config is loaded.
func Run ¶
func Run(opts RunOptions) (int, error)
Run syncs files and executes a command on the remote host. This is the main workflow that ties together all subsystems.
func RunParallelTask ¶ added in v0.11.0
func RunParallelTask(opts ParallelTaskOptions) (int, error)
RunParallelTask executes a parallel task group. Returns the aggregate exit code and any error.
func RunTask ¶
func RunTask(opts TaskOptions) (int, error)
RunTask executes a named task from the configuration. This handles the full workflow: connect, sync, lock, execute.
func SetVersionInfo ¶
func SetVersionInfo(v, c, d string)
SetVersionInfo sets the version information (called from main).
func Setup ¶
func Setup(opts SetupOptions) error
Setup configures SSH keys and tests connection to a host. This is a guided wizard that helps users get passwordless SSH working.
func Sync ¶
func Sync(opts SyncOptions) error
Sync transfers files to the remote host without executing any command.
func Update ¶ added in v0.2.1
func Update(opts UpdateOptions) error
Update checks for and installs the latest version of rr
func ValidateLocalAndTag ¶ added in v0.18.1
ValidateLocalAndTag checks that --local and --tag are not used together. These flags are mutually exclusive: --local forces local execution while --tag selects remote hosts by tag.
func WriteJSONError ¶ added in v0.11.7
WriteJSONError writes an error response to the writer.
func WriteJSONFromError ¶ added in v0.11.7
WriteJSONFromError converts a Go error to a JSON error response.
func WriteJSONSuccess ¶ added in v0.11.7
WriteJSONSuccess writes a successful response with data to the writer.
func WritePhaseEvent ¶ added in v0.21.0
func WritePhaseEvent(event PhaseEvent)
WritePhaseEvent writes a structured phase event to stderr as a JSON line.
Types ¶
type AliasStatus ¶
type AliasStatus struct {
Alias string `json:"alias"`
Status string `json:"status"` // "connected", "failed"
Latency string `json:"latency,omitempty"`
Error string `json:"error,omitempty"`
}
AliasStatus represents a single SSH alias's probe result.
type CategoryOutput ¶
type CategoryOutput struct {
Name string `json:"name"`
Results []doctor.CheckResult `json:"results"`
}
CategoryOutput represents a category of check results.
type CommonFlags ¶ added in v0.4.0
CommonFlags holds the standard flags used across run/exec/sync/task commands.
type DoctorOutput ¶
type DoctorOutput struct {
Categories []CategoryOutput `json:"categories"`
Summary SummaryOutput `json:"summary"`
}
DoctorOutput represents the JSON output for doctor command.
type FixOption ¶ added in v0.4.2
type FixOption string
FixOption represents a choice in the fix menu.
type FixResult ¶ added in v0.4.2
type FixResult struct {
Fixed bool // Whether the fix was applied
ShouldRetry bool // Whether the user wants to retry the command
Message string // Human-readable message about what happened
}
FixResult contains the result of attempting to fix a missing tool error.
func HandleMissingTool ¶ added in v0.4.2
func HandleMissingTool( missingTool *exec.MissingToolError, sshClient exec.SSHStreamer, configPath string, ) (*FixResult, error)
HandleMissingTool presents the user with options to fix a missing tool error. It returns a FixResult indicating what action was taken.
type HostAddOptions ¶ added in v0.3.0
type HostAddOptions struct {
Host string // Pre-specified SSH host/alias
Name string // Friendly name for the host
Dir string // Pre-specified remote directory
SkipProbe bool // Skip connection testing
}
HostAddOptions holds options for the host add command.
type HostConfigInfo ¶ added in v0.11.7
type HostConfigInfo struct {
Name string `json:"name"`
SSHAliases []string `json:"ssh_aliases"`
Dir string `json:"dir"`
Tags []string `json:"tags,omitempty"`
Env map[string]string `json:"env,omitempty"`
IsDefault bool `json:"is_default"`
}
HostConfigInfo represents a single host in JSON output.
type HostListOutput ¶ added in v0.11.7
type HostListOutput struct {
Hosts []HostConfigInfo `json:"hosts"`
DefaultHost string `json:"default_host,omitempty"`
}
HostListOutput represents the JSON output for host list command.
type HostStatus ¶
type HostStatus struct {
Name string `json:"name"`
Aliases []AliasStatus `json:"aliases"`
Healthy bool `json:"healthy"`
}
HostStatus represents a single host's status.
type InitOptions ¶
type InitOptions struct {
Host string // Pre-specified SSH host/alias (for non-interactive)
Name string // Friendly name for the host (for non-interactive)
Dir string // Pre-specified remote directory (for non-interactive)
Overwrite bool // Overwrite existing config without asking
NonInteractive bool // Skip prompts, use defaults
SkipProbe bool // Skip connection testing
}
InitOptions holds options for the init command.
type JSONEnvelope ¶ added in v0.11.7
type JSONEnvelope struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error *JSONError `json:"error,omitempty"`
}
JSONEnvelope wraps command output in a consistent structure for machine parsing. All --json output should use this envelope.
type JSONError ¶ added in v0.11.7
type JSONError struct {
Code string `json:"code"`
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
Details interface{} `json:"details,omitempty"`
}
JSONError provides structured error information for machine parsing.
func ErrorToJSON ¶ added in v0.11.7
ErrorToJSON converts a Go error to a JSONError with appropriate code mapping. Uses errors.As() to properly handle wrapped errors.
type ParallelTaskOptions ¶ added in v0.11.0
type ParallelTaskOptions struct {
TaskName string // Name of the parallel task
Host string // If set, only use this host
Tag string // Filter hosts by tag
Stream bool // Force stream output mode
Verbose bool // Force verbose output mode
Quiet bool // Force quiet output mode
FailFast bool // Stop on first failure (overrides task config)
MaxParallel int // Limit concurrency (overrides task config)
NoLogs bool // Don't save output to log files
DryRun bool // Show plan only, don't execute
Local bool // Force local execution
Timeout time.Duration // Per-task timeout
}
ParallelTaskOptions configures parallel task execution.
func GetParallelFlagValues ¶ added in v0.11.0
func GetParallelFlagValues(stream, verbose, quiet, failFast bool, maxParallel int, noLogs, dryRun bool) ParallelTaskOptions
GetParallelFlagValues returns a function that can be used to get parallel flag values.
type PhaseEvent ¶ added in v0.21.0
type PhaseEvent struct {
Type string `json:"type"`
Phase string `json:"phase,omitempty"`
Status string `json:"status"`
Host string `json:"host,omitempty"`
Duration float64 `json:"duration_s,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
Error string `json:"error,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
TS string `json:"ts"`
}
PhaseEvent represents a structured event emitted during workflow execution.
type PhaseReporter ¶ added in v0.21.0
type PhaseReporter interface {
PhaseStart(phase string)
PhaseComplete(phase, host string, duration time.Duration)
PhaseFailed(phase string, err error)
PhaseSkipped(phase, reason string)
Divider()
ThinDivider()
CommandPrompt(command string)
CommandComplete(exitCode int, host string, totalDuration, execDuration time.Duration)
}
PhaseReporter abstracts output for workflow phases. PrettyReporter wraps the existing spinner/phase display; StructuredReporter emits JSON events to stderr while leaving stdout clean for command output.
func NewPhaseReporter ¶ added in v0.21.0
func NewPhaseReporter(pd *ui.PhaseDisplay) PhaseReporter
NewPhaseReporter returns a StructuredReporter (default) or PrettyReporter based on the current output mode.
type PrettyReporter ¶ added in v0.21.0
type PrettyReporter struct {
// contains filtered or unexported fields
}
PrettyReporter wraps the existing PhaseDisplay, spinners, and lipgloss rendering. This is what you get with --pretty.
func (*PrettyReporter) CommandComplete ¶ added in v0.21.0
func (r *PrettyReporter) CommandComplete(exitCode int, host string, totalDuration, execDuration time.Duration)
func (*PrettyReporter) CommandPrompt ¶ added in v0.21.0
func (r *PrettyReporter) CommandPrompt(command string)
func (*PrettyReporter) Divider ¶ added in v0.21.0
func (r *PrettyReporter) Divider()
func (*PrettyReporter) PhaseComplete ¶ added in v0.21.0
func (r *PrettyReporter) PhaseComplete(phase, host string, duration time.Duration)
func (*PrettyReporter) PhaseFailed ¶ added in v0.21.0
func (r *PrettyReporter) PhaseFailed(phase string, err error)
func (*PrettyReporter) PhaseSkipped ¶ added in v0.21.0
func (r *PrettyReporter) PhaseSkipped(phase, reason string)
func (*PrettyReporter) PhaseStart ¶ added in v0.21.0
func (r *PrettyReporter) PhaseStart(phase string)
func (*PrettyReporter) ThinDivider ¶ added in v0.21.0
func (r *PrettyReporter) ThinDivider()
type ProvisionHostResult ¶ added in v0.19.0
type ProvisionHostResult struct {
Name string `json:"name"`
OS string `json:"os"`
Connected bool `json:"connected"`
Error string `json:"error,omitempty"`
Requirements []ProvisionRequirementItem `json:"requirements,omitempty"`
}
ProvisionHostResult contains results for a single host.
type ProvisionOptions ¶ added in v0.19.0
type ProvisionOptions struct {
Host string // Target specific host (empty = all project hosts)
CheckOnly bool // Report status without installing
AutoYes bool // Skip confirmation prompts
MachineOut bool // Output JSON for CI/LLM
}
ProvisionOptions configures the provision command behavior.
type ProvisionOutput ¶ added in v0.19.0
type ProvisionOutput struct {
Hosts []ProvisionHostResult `json:"hosts"`
Summary ProvisionSummary `json:"summary"`
}
ProvisionOutput is the JSON output structure for machine mode.
type ProvisionRequirementItem ¶ added in v0.19.0
type ProvisionRequirementItem struct {
Name string `json:"name"`
Satisfied bool `json:"satisfied"`
Path string `json:"path,omitempty"`
CanInstall bool `json:"canInstall"`
Installed bool `json:"installed,omitempty"`
}
ProvisionRequirementItem represents a single requirement check result.
type ProvisionSummary ¶ added in v0.19.0
type ProvisionSummary struct {
TotalHosts int `json:"totalHosts"`
ConnectedHosts int `json:"connectedHosts"`
TotalMissing int `json:"totalMissing"`
CanInstall int `json:"canInstall"`
Installed int `json:"installed"`
}
ProvisionSummary summarizes the provision operation.
type PullOptions ¶ added in v0.19.0
type PullOptions struct {
Patterns []string // Remote paths or glob patterns to pull
Dest string // Local destination directory (default: current directory)
Host string // Preferred host name
Tag string // Filter hosts by tag
ProbeTimeout time.Duration // Override SSH probe timeout (0 means use config default)
DryRun bool // If true, show what would be pulled without pulling
}
PullOptions holds options for the pull command.
type RunOptions ¶
type RunOptions struct {
Command string
Host string // Preferred host name
Tag string // Filter hosts by tag
ProbeTimeout time.Duration // Override SSH probe timeout (0 means use config default)
SkipSync bool // If true, skip sync phase (used by exec)
SkipLock bool // If true, skip locking
SkipRequirements bool // If true, skip requirement checks
DryRun bool // If true, show what would be done without doing it
WorkingDir string // Override local working directory
Quiet bool // If true, minimize output (no individual connection attempts)
Local bool // If true, force local execution (skip remote hosts)
Pull []string // Patterns to pull from remote after command completes
PullDest string // Destination directory for pulled files
}
RunOptions holds options for the run command.
type SetupOptions ¶
SetupOptions holds options for the setup command.
type StatusOutput ¶
type StatusOutput struct {
Hosts []HostStatus `json:"hosts"`
Selected *Selected `json:"selected,omitempty"`
}
StatusOutput represents the JSON output for status command.
type StructuredReporter ¶ added in v0.21.0
type StructuredReporter struct{}
StructuredReporter emits JSON events to stderr. stdout is left clean for raw command output.
func (*StructuredReporter) CommandComplete ¶ added in v0.21.0
func (r *StructuredReporter) CommandComplete(exitCode int, host string, totalDuration, execDuration time.Duration)
func (*StructuredReporter) CommandPrompt ¶ added in v0.21.0
func (r *StructuredReporter) CommandPrompt(command string)
func (*StructuredReporter) Divider ¶ added in v0.21.0
func (r *StructuredReporter) Divider()
func (*StructuredReporter) PhaseComplete ¶ added in v0.21.0
func (r *StructuredReporter) PhaseComplete(phase, host string, duration time.Duration)
func (*StructuredReporter) PhaseFailed ¶ added in v0.21.0
func (r *StructuredReporter) PhaseFailed(phase string, err error)
func (*StructuredReporter) PhaseSkipped ¶ added in v0.21.0
func (r *StructuredReporter) PhaseSkipped(phase, reason string)
func (*StructuredReporter) PhaseStart ¶ added in v0.21.0
func (r *StructuredReporter) PhaseStart(phase string)
func (*StructuredReporter) ThinDivider ¶ added in v0.21.0
func (r *StructuredReporter) ThinDivider()
type SummaryOutput ¶
type SummaryOutput struct {
Pass int `json:"pass"`
Warn int `json:"warn"`
Fail int `json:"fail"`
Fixable int `json:"fixable"`
AllClear bool `json:"all_clear"`
}
SummaryOutput summarizes the check results.
type SyncOptions ¶
type SyncOptions struct {
Host string // Preferred host name
Tag string // Filter hosts by tag
ProbeTimeout time.Duration // Override SSH probe timeout (0 means use config default)
DryRun bool // If true, show what would be synced without syncing
SkipLock bool // If true, skip locking
WorkingDir string // Override local working directory
}
SyncOptions holds options for the sync command.
type TaskInfo ¶ added in v0.11.7
type TaskInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"` // "single", "multi-step", "parallel"
Command string `json:"command,omitempty"`
Steps []string `json:"steps,omitempty"`
Subtasks []string `json:"subtasks,omitempty"`
Hosts []string `json:"hosts,omitempty"`
}
TaskInfo represents a single task in JSON output.
type TaskOptions ¶
type TaskOptions struct {
TaskName string
Args []string // Extra arguments to append to task command
Host string // Preferred host name
Tag string // Filter hosts by tag
ProbeTimeout time.Duration // Override SSH probe timeout
SkipSync bool // If true, skip sync phase
SkipLock bool // If true, skip locking
DryRun bool // If true, show what would be done without doing it
WorkingDir string // Override local working directory
Quiet bool // If true, minimize output
Local bool // If true, force local execution (skip remote hosts)
SkipDeps bool // If true, skip dependencies and run only this task
From string // If set, start from this task in the dependency chain
}
TaskOptions holds options for task execution.
type TasksOutput ¶ added in v0.11.7
type TasksOutput struct {
Tasks []TaskInfo `json:"tasks"`
}
TasksOutput represents the JSON output for tasks command.
type UnlockOptions ¶ added in v0.4.6
type UnlockOptions struct {
Host string // Specific host to unlock (empty for default or picker)
All bool // Unlock all configured hosts
}
UnlockOptions holds options for the unlock command.
type UpdateOptions ¶ added in v0.2.1
type UpdateOptions struct {
Force bool // Force update even if already on latest
Check bool // Just check for updates, don't install
}
UpdateOptions holds options for the update command.
type WorkflowContext ¶
type WorkflowContext struct {
Resolved *config.ResolvedConfig
Conn *host.Connection
Lock *lock.Lock
WorkDir string
PhaseDisplay *ui.PhaseDisplay
Reporter PhaseReporter
StartTime time.Time
// contains filtered or unexported fields
}
WorkflowContext holds state from workflow setup for use during execution.
func SetupWorkflow ¶
func SetupWorkflow(opts WorkflowOptions) (*WorkflowContext, error)
SetupWorkflow performs the common workflow phases: load config, connect, lock, and sync. Returns a WorkflowContext that the caller uses for execution, and must Close() when done.
When multiple hosts are configured, this function implements load balancing: 1. Try each host with non-blocking lock acquisition 2. If a host is locked, immediately try the next host 3. If all hosts are locked and local_fallback is true, run locally 4. If all hosts are locked and local_fallback is false, round-robin wait 5. Once a lock is acquired, sync files to that host
The lock-before-sync order ensures we don't waste time syncing to a host we can't use.
func (*WorkflowContext) Close ¶
func (w *WorkflowContext) Close()
Close releases workflow resources. Safe to call multiple times.
func (*WorkflowContext) Context ¶ added in v0.21.0
func (w *WorkflowContext) Context() context.Context
Context returns the workflow's cancellable context. This context is cancelled when the user sends SIGINT/SIGTERM, allowing callers to propagate cancellation to remote commands.
func (*WorkflowContext) GetReporter ¶ added in v0.21.0
func (w *WorkflowContext) GetReporter() PhaseReporter
GetReporter returns the workflow's phase reporter, lazily initializing if needed.
type WorkflowOptions ¶
type WorkflowOptions struct {
Host string // Preferred host name
Tag string // Filter hosts by tag
ProbeTimeout time.Duration // Override SSH probe timeout
SkipSync bool // Skip file sync phase
SkipLock bool // Skip lock acquisition
SkipRequirements bool // Skip requirement checks
WorkingDir string // Override local working directory
Quiet bool // Minimize output
Local bool // Force local execution (skip remote hosts)
Command string // Command being run (stored in lock for monitoring)
TaskName string // Task name for task-specific requirements
}
WorkflowOptions configures workflow setup behavior.