command

package
v0.15.7 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CommandReset represents the /reset command
	CommandReset = "/reset"
	// CommandDisconnect represents the /dc command
	CommandDisconnect = "/dc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DisconnectExecutor

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

DisconnectExecutor implements the /dc command

func NewDisconnectExecutor

func NewDisconnectExecutor(eng *engine.Engine) *DisconnectExecutor

NewDisconnectExecutor creates a new disconnect command executor

func (*DisconnectExecutor) Command

func (e *DisconnectExecutor) Command() string

Command returns the command name

func (*DisconnectExecutor) Description

func (e *DisconnectExecutor) Description() string

Description returns the command description

func (*DisconnectExecutor) Execute

func (e *DisconnectExecutor) Execute(ctx context.Context, req *Request, callback event.Callback) (*Result, error)

Execute runs the disconnect command

type Executor

type Executor interface {
	// Command returns the command name (e.g., "/reset")
	Command() string

	// Description returns a human-readable description
	Description() string

	// Execute runs the command, sending progress updates via callback
	Execute(ctx context.Context, req *Request, callback event.Callback) (*Result, error)
}

Executor defines the interface for slash command executors. Each command (/reset, /dc, etc.) implements this interface.

type ProgressEmitter

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

ProgressEmitter sends progress events during command execution

func NewProgressEmitter

func NewProgressEmitter(command string, callback event.Callback, steps []ProgressStep) *ProgressEmitter

NewProgressEmitter creates a new progress emitter

func (*ProgressEmitter) Complete

func (e *ProgressEmitter) Complete(message string) error

Complete sends the final completion event

func (*ProgressEmitter) Emit

func (e *ProgressEmitter) Emit(title string) error

Emit sends the current progress state

func (*ProgressEmitter) Error

func (e *ProgressEmitter) Error(stepIndex int, message string) error

Error marks a step as failed

func (*ProgressEmitter) GetSteps

func (e *ProgressEmitter) GetSteps() []ProgressStep

GetSteps returns current steps (for external use)

func (*ProgressEmitter) Running

func (e *ProgressEmitter) Running(stepIndex int) error

Running marks a step as running

func (*ProgressEmitter) Start

func (e *ProgressEmitter) Start(title string) error

Start sends initial progress with all steps in pending state

func (*ProgressEmitter) Success

func (e *ProgressEmitter) Success(stepIndex int, message string) error

Success marks a step as successful

func (*ProgressEmitter) UpdateStep

func (e *ProgressEmitter) UpdateStep(stepIndex int, status, message string) error

UpdateStep updates a specific step and emits progress

type ProgressStep

type ProgressStep struct {
	Name    string // Step identifier (e.g., "find_session")
	Message string // Human-readable message
	Status  string // "pending", "running", "success", "error"
}

ProgressStep represents a single step in command execution

type Registry

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

Registry manages all registered command executors

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new command registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, req *Request, callback event.Callback) (*Result, error)

Execute runs a command by name

func (*Registry) Get

func (r *Registry) Get(command string) (Executor, bool)

Get retrieves a command executor by name

func (*Registry) List

func (r *Registry) List() []string

List returns all registered commands

func (*Registry) Register

func (r *Registry) Register(exec Executor)

Register adds a command executor to the registry

type Request

type Request struct {
	Command           string         // Original command (e.g., "/reset")
	Text              string         // Command arguments
	UserID            string         // User who invoked the command
	ChannelID         string         // Channel where command was invoked
	SessionID         string         // Associated session ID
	ProviderSessionID string         // Provider session ID (if available)
	ResponseURL       string         // Slack response_url (optional)
	Metadata          map[string]any // Platform-specific metadata
}

Request encapsulates a slash command request

type ResetExecutor

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

ResetExecutor implements the /reset command

func NewResetExecutor

func NewResetExecutor(eng *engine.Engine, workDir string) *ResetExecutor

NewResetExecutor creates a new reset command executor

func (*ResetExecutor) Command

func (e *ResetExecutor) Command() string

Command returns the command name

func (*ResetExecutor) Description

func (e *ResetExecutor) Description() string

Description returns the command description

func (*ResetExecutor) Execute

func (e *ResetExecutor) Execute(ctx context.Context, req *Request, callback event.Callback) (*Result, error)

Execute runs the reset command

type Result

type Result struct {
	Success  bool
	Message  string         // Final message to display
	Metadata map[string]any // Result metadata
}

Result encapsulates command execution result

Jump to

Keyboard shortcuts

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