commands

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClearCommand

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

ClearCommand clears the conversation history

func NewClearCommand

func NewClearCommand(repo domain.ConversationRepository) *ClearCommand

func (*ClearCommand) CanExecute

func (c *ClearCommand) CanExecute(args []string) bool

func (*ClearCommand) Execute

func (c *ClearCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ClearCommand) GetDescription

func (c *ClearCommand) GetDescription() string

func (*ClearCommand) GetName

func (c *ClearCommand) GetName() string

func (*ClearCommand) GetUsage

func (c *ClearCommand) GetUsage() string

type Command

type Command interface {
	GetName() string
	GetDescription() string
	GetUsage() string
	Execute(ctx context.Context, args []string) (CommandResult, error)
	CanExecute(args []string) bool
}

Command interface represents a chat command that can be executed

type CommandResult

type CommandResult struct {
	Output     string
	Success    bool
	SideEffect SideEffectType
	Data       interface{} // Additional data for the side effect
}

CommandResult represents the result of a command execution

type ExitCommand

type ExitCommand struct{}

ExitCommand exits the application

func NewExitCommand

func NewExitCommand() *ExitCommand

func (*ExitCommand) CanExecute

func (c *ExitCommand) CanExecute(args []string) bool

func (*ExitCommand) Execute

func (c *ExitCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ExitCommand) GetDescription

func (c *ExitCommand) GetDescription() string

func (*ExitCommand) GetName

func (c *ExitCommand) GetName() string

func (*ExitCommand) GetUsage

func (c *ExitCommand) GetUsage() string

type ExportCommand

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

ExportCommand exports the conversation

func NewExportCommand

func NewExportCommand(repo domain.ConversationRepository, chatService domain.ChatService, modelService domain.ModelService, config *config.Config) *ExportCommand

func (*ExportCommand) CanExecute

func (c *ExportCommand) CanExecute(args []string) bool

func (*ExportCommand) Execute

func (c *ExportCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ExportCommand) GetDescription

func (c *ExportCommand) GetDescription() string

func (*ExportCommand) GetName

func (c *ExportCommand) GetName() string

func (*ExportCommand) GetUsage

func (c *ExportCommand) GetUsage() string

func (*ExportCommand) PerformExport

func (c *ExportCommand) PerformExport(ctx context.Context) (string, error)

PerformExport performs the actual export operation (called by side effect handler)

type HelpCommand

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

HelpCommand shows available commands

func NewHelpCommand

func NewHelpCommand(registry *Registry) *HelpCommand

func (*HelpCommand) CanExecute

func (c *HelpCommand) CanExecute(args []string) bool

func (*HelpCommand) Execute

func (c *HelpCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*HelpCommand) GetDescription

func (c *HelpCommand) GetDescription() string

func (*HelpCommand) GetName

func (c *HelpCommand) GetName() string

func (*HelpCommand) GetUsage

func (c *HelpCommand) GetUsage() string

type HistoryCommand

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

HistoryCommand shows conversation history

func NewHistoryCommand

func NewHistoryCommand(repo domain.ConversationRepository) *HistoryCommand

func (*HistoryCommand) CanExecute

func (c *HistoryCommand) CanExecute(args []string) bool

func (*HistoryCommand) Execute

func (c *HistoryCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*HistoryCommand) GetDescription

func (c *HistoryCommand) GetDescription() string

func (*HistoryCommand) GetName

func (c *HistoryCommand) GetName() string

func (*HistoryCommand) GetUsage

func (c *HistoryCommand) GetUsage() string

type ModelsCommand

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

ModelsCommand shows available models

func NewModelsCommand

func NewModelsCommand(modelService domain.ModelService) *ModelsCommand

func (*ModelsCommand) CanExecute

func (c *ModelsCommand) CanExecute(args []string) bool

func (*ModelsCommand) Execute

func (c *ModelsCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ModelsCommand) GetDescription

func (c *ModelsCommand) GetDescription() string

func (*ModelsCommand) GetName

func (c *ModelsCommand) GetName() string

func (*ModelsCommand) GetUsage

func (c *ModelsCommand) GetUsage() string

type Registry

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

Registry manages all available commands

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new command registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, args []string) (CommandResult, error)

Execute executes a command by name with arguments

func (*Registry) Get

func (r *Registry) Get(name string) (Command, bool)

Get retrieves a command by name

func (*Registry) GetAll

func (r *Registry) GetAll() []Command

GetAll returns all registered commands

func (*Registry) GetCommands added in v0.16.0

func (r *Registry) GetCommands() map[string]string

GetCommands returns a map of command names to descriptions

func (*Registry) GetCommandsStartingWith

func (r *Registry) GetCommandsStartingWith(prefix string) []string

GetCommandsStartingWith returns commands that start with the given prefix

func (*Registry) List

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

List returns all registered command names

func (*Registry) ParseCommand

func (r *Registry) ParseCommand(input string) (string, []string, error)

ParseCommand parses a command line input into command name and arguments

func (*Registry) Register

func (r *Registry) Register(cmd Command)

Register adds a command to the registry

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

Unregister removes a command from the registry

type SideEffectType

type SideEffectType int

SideEffectType defines the types of side effects a command can have

const (
	SideEffectNone SideEffectType = iota
	SideEffectClearConversation
	SideEffectExportConversation
	SideEffectExit
	SideEffectSwitchModel
	SideEffectShowHistory
	SideEffectShowHelp
)

type SwitchCommand

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

SwitchCommand switches the active model

func NewSwitchCommand

func NewSwitchCommand(modelService domain.ModelService) *SwitchCommand

func (*SwitchCommand) CanExecute

func (c *SwitchCommand) CanExecute(args []string) bool

func (*SwitchCommand) Execute

func (c *SwitchCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*SwitchCommand) GetDescription

func (c *SwitchCommand) GetDescription() string

func (*SwitchCommand) GetName

func (c *SwitchCommand) GetName() string

func (*SwitchCommand) GetUsage

func (c *SwitchCommand) GetUsage() string

Jump to

Keyboard shortcuts

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