cli

package
v0.1.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli adapts arcave's services to Cobra commands: each handler invokes a service method and renders the result through a printer — the model types go out as JSON (Savepoint for single-savepoint payloads, the response envelopes for multi-part responses). The printer is injected, so handlers are unit- testable without touching stdout. Command definitions and flags live in cmd/arcave, which resolves the config and logger before RunE and passes typed arguments here — the handlers know nothing of cobra or viper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateGarbageCollectRequest

func ValidateGarbageCollectRequest(req model.GarbageCollectRequest) error

ValidateGarbageCollectRequest refuses, before anything is opened, a request the service would refuse.

func WithFixHint

func WithFixHint(err error) error

WithFixHint adds the CLI's fix to a current-session error; any other passes unchanged.

Types

type ConfigInitHandler

type ConfigInitHandler struct {
	// contains filtered or unexported fields
}

func NewConfigInitHandler

func NewConfigInitHandler(svc configInitService, printer printer) *ConfigInitHandler

func (*ConfigInitHandler) Init

func (h *ConfigInitHandler) Init(ctx context.Context, cfg config.Config, override bool) error

type DownHandler

type DownHandler struct {
	// contains filtered or unexported fields
}

DownHandler ends a compose project's environment on the daemon.

func NewDownHandler

func NewDownHandler(svc downService, printer printer) *DownHandler

func (*DownHandler) Down

func (h *DownHandler) Down(ctx context.Context, force bool) error

Down takes the environment off the daemon and prints what went.

type GCHandler

type GCHandler struct {
	// contains filtered or unexported fields
}

func NewGCHandler

func NewGCHandler(svc gcService, printer printer) *GCHandler

func (*GCHandler) GarbageCollect

func (h *GCHandler) GarbageCollect(ctx context.Context, req model.GarbageCollectRequest) error

GarbageCollect runs req and prints the report; a partial gc, one stopped midway through deleting included, prints it and still fails.

type MCPDownService

type MCPDownService interface {
	Down(ctx context.Context, req model.DownRequest) (model.DownResult, error)
}

MCPDownService is the MCP adapter's view of down.

type MCPDownServiceFactory

type MCPDownServiceFactory func(
	ctx context.Context, composeProject, session string,
) (svc MCPDownService, release func(), err error)

MCPDownServiceFactory builds down for one compose project in the named session ("" is the current one) plus its release: the daemon and the marker, nothing a capture or restore needs.

type MCPFactories

MCPFactories builds what each family of tools runs on, once per tool call.

type MCPGCService

type MCPGCService interface {
	GarbageCollect(ctx context.Context, req model.GarbageCollectRequest) (model.GarbageCollectResult, error)
}

MCPGCService is the MCP adapter's view of gc.

type MCPGCServiceFactory

type MCPGCServiceFactory func(ctx context.Context, session string) (svc MCPGCService, release func(), err error)

MCPGCServiceFactory builds a gc for one tool call's session ref ("" is the current one), plus the release the tool call invokes on return.

type MCPHandler

type MCPHandler struct {
	// contains filtered or unexported fields
}

MCPHandler serves arcave's savepoint and session workflows as MCP tools over stdio. stdout is the JSON-RPC channel, so nothing here may write to it; logs go to stderr.

func NewMCPHandler

func NewMCPHandler(
	factories MCPFactories, pinnedSession model.SessionID, pinSource model.SessionRefSource,
	rollbackConfig RollbackConfig,
) *MCPHandler

NewMCPHandler builds the MCP adapter; pinnedSession is the session the server was started in, zero to follow the current one, and pinSource what named it.

func (*MCPHandler) MCPRun

func (h *MCPHandler) MCPRun(ctx context.Context) error

MCPRun serves the tools over stdio until the host closes stdin or ctx is cancelled. A cancelled ctx cancels no tool call: the server exits once the calls in flight have finished.

func (*MCPHandler) Server

func (h *MCPHandler) Server() *mcpsdk.Server

Server is the MCP server with every tool registered, for any transport.

type MCPSavepointService

type MCPSavepointService interface {
	CreateSavepoint(ctx context.Context, req model.CreateSavepointRequest) (model.Savepoint, error)
	Rollback(ctx context.Context, req model.RollbackRequest) (model.RollbackResult, error)
	Up(ctx context.Context, req model.UpRequest) (model.UpResult, error)
}

MCPSavepointService is the MCP adapter's view of the savepoint workflows that reach the daemon.

type MCPSavepointServiceFactory

type MCPSavepointServiceFactory func(
	ctx context.Context, composeProject, session string,
) (svc MCPSavepointService, release func(), err error)

MCPSavepointServiceFactory builds the workflows for one compose project in the named session ("" is the current one) plus their release.

type MCPSavepointStoreService

type MCPSavepointStoreService interface {
	ListSavepoints(ctx context.Context, req model.ListRequest) ([]model.Savepoint, error)
	RemoveSavepoints(ctx context.Context, req model.RemoveRequest) (model.RemoveResult, error)
}

MCPSavepointStoreService is the MCP adapter's view of the savepoint workflows over the store alone.

type MCPSavepointStoreServiceFactory

type MCPSavepointStoreServiceFactory func(
	ctx context.Context, composeProject, session string,
) (svc MCPSavepointStoreService, release func(), err error)

MCPSavepointStoreServiceFactory is MCPSavepointServiceFactory for the workflows over the store alone.

type MCPSessionService

type MCPSessionService interface {
	CurrentSession(ctx context.Context, ref model.CurrentSessionRef) (model.CurrentSession, error)
	ShowSession(ctx context.Context, req model.ShowSessionRequest) (model.SessionDetail, error)
	ListSessions(ctx context.Context, req model.ListSessionsRequest) ([]model.SessionSummary, error)
	CreateSession(ctx context.Context, req model.CreateSessionRequest) (model.Session, error)
	RemoveSession(ctx context.Context, req model.RemoveSessionRequest) (model.RemoveSessionResponse, error)
	SetSession(ctx context.Context, ref string) (model.Session, error)
	UnsetSession(ctx context.Context) (model.Session, error)
}

MCPSessionService is the MCP adapter's view of the session commands.

type MCPSessionServiceFactory

type MCPSessionServiceFactory func(ctx context.Context) (svc MCPSessionService, release func(), err error)

MCPSessionServiceFactory builds the session commands, plus the release the tool call invokes on return.

type MCPStatusService

type MCPStatusService interface {
	Status(ctx context.Context, req model.StatusRequest) (model.ComposeProjectStatus, error)
}

MCPStatusService is the MCP adapter's view of status.

type MCPStatusServiceFactory

type MCPStatusServiceFactory func(ctx context.Context, composeProject string) (svc MCPStatusService, release func(), err error)

MCPStatusServiceFactory builds a status for one compose project, plus the release the tool call invokes on return; the service resolves the session itself.

type RollbackConfig

type RollbackConfig struct {
	SkipSafetySnapshot bool
}

RollbackConfig is the project's config as the rollback tool reads it; a call may override SkipSafetySnapshot alone.

type RollbackHandler

type RollbackHandler struct {
	// contains filtered or unexported fields
}

func NewRollbackHandler

func NewRollbackHandler(svc rollbackService, printer printer) *RollbackHandler

func (*RollbackHandler) Rollback

func (h *RollbackHandler) Rollback(ctx context.Context, cfg config.Config, ref string) error

Rollback restores a savepoint and prints what was restored; whether a safety snapshot is taken comes from cfg, the wait bound is the provider's own.

type SavepointCreateHandler

type SavepointCreateHandler struct {
	// contains filtered or unexported fields
}

func NewSavepointCreateHandler

func NewSavepointCreateHandler(svc savepointCreateService, printer printer) *SavepointCreateHandler

func (*SavepointCreateHandler) SavepointCreate

func (h *SavepointCreateHandler) SavepointCreate(ctx context.Context, name, description string) error

SavepointCreate creates a savepoint and prints its metadata as JSON. The health-check bound is the provider's own (compose.wait_timeout, --wait-timeout).

type SavepointListHandler

type SavepointListHandler struct {
	// contains filtered or unexported fields
}

func NewSavepointListHandler

func NewSavepointListHandler(svc savepointListService, printer printer) *SavepointListHandler

func (*SavepointListHandler) SavepointList

func (h *SavepointListHandler) SavepointList(ctx context.Context, req model.ListRequest) error

SavepointList prints the savepoints req asks for as a JSON array. It reads only the savepoint store, so it needs no config.

type SavepointRemoveHandler

type SavepointRemoveHandler struct {
	// contains filtered or unexported fields
}

SavepointRemoveHandler holds the services the CLI adapter delegates to and the printer that renders their results.

func NewSavepointRemoveHandler

func NewSavepointRemoveHandler(svc savepointRemoveService, printer printer) *SavepointRemoveHandler

func (*SavepointRemoveHandler) SavepointRemove

func (h *SavepointRemoveHandler) SavepointRemove(ctx context.Context, req model.RemoveRequest) error

SavepointRemove removes savepoints and prints what was (or would be) removed.

type SessionCreateHandler

type SessionCreateHandler struct {
	// contains filtered or unexported fields
}

func NewSessionCreateHandler

func NewSessionCreateHandler(svc sessionCreateService, printer printer) *SessionCreateHandler

func (*SessionCreateHandler) SessionCreate

SessionCreate creates a session, empty or a clone of req.From, and prints its record.

type SessionCurrentHandler

type SessionCurrentHandler struct {
	// contains filtered or unexported fields
}

func NewSessionCurrentHandler

func NewSessionCurrentHandler(svc sessionCurrentService, printer printer) *SessionCurrentHandler

func (*SessionCurrentHandler) SessionCurrent

func (h *SessionCurrentHandler) SessionCurrent(ctx context.Context, ref model.CurrentSessionRef) error

SessionCurrent prints the session a command works in: ref when set, else the current session, else the default.

type SessionListHandler

type SessionListHandler struct {
	// contains filtered or unexported fields
}

func NewSessionListHandler

func NewSessionListHandler(svc sessionListService, printer printer) *SessionListHandler

func (*SessionListHandler) SessionList

SessionList prints the arcave project's sessions as a JSON array in req.Sort's order; req.All adds the trees without a record, each with its status.

type SessionRemoveHandler

type SessionRemoveHandler struct {
	// contains filtered or unexported fields
}

func NewSessionRemoveHandler

func NewSessionRemoveHandler(svc sessionRemoveService, printer printer) *SessionRemoveHandler

func (*SessionRemoveHandler) SessionRemove

SessionRemove removes a session by id or name, or a recordless tree by id, and prints which one went and the bytes it freed.

type SessionSetHandler

type SessionSetHandler struct {
	// contains filtered or unexported fields
}

func NewSessionSetHandler

func NewSessionSetHandler(svc sessionSetService, printer printer) *SessionSetHandler

func (*SessionSetHandler) SessionSet

func (h *SessionSetHandler) SessionSet(ctx context.Context, ref string) error

SessionSet makes the session ref names the current one and prints its record.

type SessionShowHandler

type SessionShowHandler struct {
	// contains filtered or unexported fields
}

func NewSessionShowHandler

func NewSessionShowHandler(svc sessionShowService, printer printer) *SessionShowHandler

func (*SessionShowHandler) SessionShow

SessionShow prints a session and its savepoints by compose project.

type SessionUnsetHandler

type SessionUnsetHandler struct {
	// contains filtered or unexported fields
}

func NewSessionUnsetHandler

func NewSessionUnsetHandler(svc sessionUnsetService, printer printer) *SessionUnsetHandler

func (*SessionUnsetHandler) SessionUnset

func (h *SessionUnsetHandler) SessionUnset(ctx context.Context) error

SessionUnset clears the current-session pointer and prints the session commands now work in.

type StatusHandler

type StatusHandler struct {
	// contains filtered or unexported fields
}

func NewStatusHandler

func NewStatusHandler(svc statusService, printer printer) *StatusHandler

func (*StatusHandler) Status

func (h *StatusHandler) Status(ctx context.Context, req model.StatusRequest) error

Status prints what the daemon runs for the compose project; a partial status prints it and still fails.

type UpHandler

type UpHandler struct {
	// contains filtered or unexported fields
}

UpHandler brings a compose project up from a savepoint, never over anything unless forced.

func NewUpHandler

func NewUpHandler(svc upService, printer printer) *UpHandler

func (*UpHandler) Up

func (h *UpHandler) Up(ctx context.Context, ref string, force bool) error

Up builds the compose project from ref — the newest savepoint when empty — and prints what was built and, when forced over a present one, what was dropped; the wait bound is the provider's.

Jump to

Keyboard shortcuts

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