Documentation
¶
Overview ¶
Package cli provides shared types and utilities for CLI commands. This package is designed to be imported by both cmd/moat/cli and internal/providers/*/cli.go to avoid import cycles.
IMPORTANT: This package MUST NOT import internal/run or internal/providers to avoid import cycles. Only put types and utility functions here that don't depend on the run or provider packages.
Index ¶
- Variables
- func AddExecFlags(cmd *cobra.Command, flags *ExecFlags)
- func HasDependency(deps []string, prefix string) bool
- func ParseEnvFlags(envFlags []string, cfg *config.Config) error
- func ResolveWorkspacePath(workspace string) (string, error)
- type ExecFlags
- type ExecOptions
- type ExecResult
- type RunInfo
Constants ¶
This section is empty.
Variables ¶
var ( // DryRun is set by the --dry-run flag DryRun bool // RootCmd is the root cobra command, needed for providers to add subcommands RootCmd *cobra.Command // ExecuteRun is the function that executes a containerized command. // This is set by cmd/moat/cli to avoid import cycles. // It accepts ExecOptions and returns (*ExecResult, error). ExecuteRun func(ctx context.Context, opts ExecOptions) (*ExecResult, error) )
Global state that providers need access to. These are set by cmd/moat/cli/root.go during initialization.
Functions ¶
func AddExecFlags ¶
AddExecFlags adds the common execution flags to a command.
func HasDependency ¶
HasDependency checks if a dependency prefix exists in the list. Matches exact name (e.g., "node") or name with version (e.g., "node@20").
func ParseEnvFlags ¶
ParseEnvFlags validates and parses environment variable flags into the config.
func ResolveWorkspacePath ¶
ResolveWorkspacePath resolves and validates a workspace path argument. Returns the absolute, symlink-resolved path.
Types ¶
type ExecFlags ¶
type ExecFlags struct {
Grants []string
Env []string
Name string
Runtime string
Rebuild bool
KeepContainer bool
Detach bool
Interactive bool
NoSandbox bool
TTYTrace string // Path to save terminal I/O trace for debugging
}
ExecFlags holds the common flags for container execution commands. These are shared between `moat run`, `moat claude`, and future tool commands.
type ExecOptions ¶
type ExecOptions struct {
// From flags
Flags ExecFlags
// Command-specific
Workspace string
Command []string
Config *config.Config
Interactive bool // Can be set by flags or command logic
TTY bool
// Callbacks for command-specific behavior
// OnRunCreated is called after run is created, before start.
// The RunInfo parameter contains the run's ID and Name.
OnRunCreated func(info RunInfo)
}
ExecOptions contains all the options needed to execute a containerized command.
type ExecResult ¶
ExecResult contains the result of executing a run. This is returned instead of *run.Run to avoid import cycles.