command

package
v0.31.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteSync

func ExecuteSync(ctx context.Context, exec Executor) error

ExecuteSync runs an executor synchronously, blocking until completion. Streaming output is discarded. Returns the final error.

Types

type Action

type Action struct {
	Type        ActionType
	Key         string
	Help        string
	Confirm     string // Non-empty if confirmation required
	ShellCmd    string // For shell actions, the rendered command
	SessionID   string
	SessionPath string
	Silent      bool  // Skip loading popup for fast commands
	Exit        bool  // Exit hive after command completes
	Err         error // Non-nil if action resolution failed (e.g., template error)
}

Action represents a resolved command action ready for execution.

func (Action) NeedsConfirm

func (a Action) NeedsConfirm() bool

NeedsConfirm returns true if the action requires user confirmation.

type ActionType

type ActionType int

ActionType identifies the kind of action.

const (
	ActionTypeNone ActionType = iota
	ActionTypeRecycle
	ActionTypeDelete
	ActionTypeShell
)

type DeleteExecutor

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

DeleteExecutor executes a session delete operation.

func (*DeleteExecutor) Execute

func (e *DeleteExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)

Execute deletes the session asynchronously. Returns nil output channel (non-streaming).

type Executor

type Executor interface {
	// Execute runs the command asynchronously. Returns:
	// - output: streaming output lines (nil for non-streaming commands)
	// - done: receives error (or nil) when complete
	// - cancel: cancels the operation
	Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
}

Executor executes a command, optionally with streaming output.

type RecycleExecutor

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

RecycleExecutor executes a session recycle operation with streaming output.

func (*RecycleExecutor) Execute

func (e *RecycleExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)

Execute starts the recycle operation and returns channels for output and completion. Returns non-nil output channel with streaming recycle progress.

type Service

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

Service creates command executors based on action type.

func NewService

func NewService(deleter SessionDeleter, recycler SessionRecycler) *Service

NewService creates a new command service with the given dependencies.

func (*Service) CreateExecutor

func (s *Service) CreateExecutor(action Action) (Executor, error)

CreateExecutor creates an executor for the given action. Returns error if the action type is not supported.

type SessionDeleter

type SessionDeleter interface {
	DeleteSession(ctx context.Context, id string) error
}

SessionDeleter is the interface for deleting sessions.

type SessionRecycler

type SessionRecycler interface {
	RecycleSession(ctx context.Context, id string, w io.Writer) error
}

SessionRecycler is the interface for recycling sessions.

type ShellExecutor

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

ShellExecutor executes a shell command.

func (*ShellExecutor) Execute

func (e *ShellExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)

Execute runs the shell command asynchronously. Returns nil output channel (non-streaming).

Jump to

Keyboard shortcuts

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