cli

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func AddExecFlags(cmd *cobra.Command, flags *ExecFlags)

AddExecFlags adds the common execution flags to a command.

func HasDependency

func HasDependency(deps []string, prefix string) bool

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

func ParseEnvFlags(envFlags []string, cfg *config.Config) error

ParseEnvFlags validates and parses environment variable flags into the config.

func ResolveWorkspacePath

func ResolveWorkspacePath(workspace string) (string, error)

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

type ExecResult struct {
	ID   string
	Name string
}

ExecResult contains the result of executing a run. This is returned instead of *run.Run to avoid import cycles.

type RunInfo

type RunInfo struct {
	ID   string
	Name string
}

RunInfo contains minimal information about a run, extracted to avoid import cycles. This is passed to callbacks instead of the full *run.Run type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL