commands

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPersistentFlags

func AddPersistentFlags(cmd *cobra.Command, opts *SharedOptions)

AddPersistentFlags adds common flags to a command

func PrintError

func PrintError(format string, args ...interface{})

PrintError prints an error message with consistent formatting

func PrintInfo

func PrintInfo(format string, args ...interface{})

PrintInfo prints an info message with consistent formatting

func PrintSuccess

func PrintSuccess(format string, args ...interface{})

PrintSuccess prints a success message with consistent formatting

func PrintWarning

func PrintWarning(format string, args ...interface{})

PrintWarning prints a warning message with consistent formatting

func SetupColors

func SetupColors(noColor bool)

SetupColors configures color output based on options

func SetupProgress

func SetupProgress(opts *SharedOptions)

SetupProgress initializes the progress manager with options

Types

type BaseCommand

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

BaseCommand provides shared execution patterns for commands

func NewBaseCommand

func NewBaseCommand(executor CommandExecutor) *BaseCommand

NewBaseCommand creates a new base command with the specified executor

func (*BaseCommand) ExecuteWithCommonPattern

func (bc *BaseCommand) ExecuteWithCommonPattern(sharedCtx *SharedContext, sourceName string) error

ExecuteWithCommonPattern executes command logic using the common pattern

type Command

type Command interface {
	// Name returns the command name
	Name() string

	// Description returns the command description
	Description() string

	// CreateCommand creates the cobra command
	CreateCommand(sharedCtx *SharedContext) *cobra.Command
}

Command interface for structured command implementations

type CommandExecutor

type CommandExecutor interface {
	// ExecuteOperation performs the actual command operation
	ExecuteOperation(ctx *SharedContext, sources []config.Source) error

	// GetOperationName returns a human-readable name for the operation (e.g., "Installing", "Updating")
	GetOperationName() string

	// GetCompletionMessage returns the completion message for successful operations
	GetCompletionMessage() string

	// ShouldContinueOnError returns true if the operation should continue when individual sources fail
	ShouldContinueOnError(ctx *SharedContext) bool
}

CommandExecutor defines the interface for command-specific execution logic

type CommandRegistry

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

CommandRegistry manages all available commands

func NewCommandRegistry

func NewCommandRegistry() *CommandRegistry

NewCommandRegistry creates a new command registry with all available commands

func (*CommandRegistry) CreateRootCommand

func (r *CommandRegistry) CreateRootCommand(version string) *cobra.Command

CreateRootCommand creates the root cobra command with all subcommands

type IndexCommand

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

IndexCommand implements the index command functionality

func NewIndexCommand

func NewIndexCommand() *IndexCommand

NewIndexCommand creates a new index command instance

func (*IndexCommand) CreateCommand

func (c *IndexCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for index functionality

func (*IndexCommand) Description

func (c *IndexCommand) Description() string

Description returns the command description

func (*IndexCommand) Execute

func (c *IndexCommand) Execute(sharedCtx *SharedContext) error

Execute runs the index command logic

func (*IndexCommand) Name

func (c *IndexCommand) Name() string

Name returns the command name

type InstallCommand

type InstallCommand struct {
	*BaseCommand
	// contains filtered or unexported fields
}

InstallCommand implements the install command functionality

func NewInstallCommand

func NewInstallCommand() *InstallCommand

NewInstallCommand creates a new install command instance

func (*InstallCommand) CreateCommand

func (c *InstallCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for install functionality

func (*InstallCommand) Description

func (c *InstallCommand) Description() string

Description returns the command description

func (*InstallCommand) Execute

func (c *InstallCommand) Execute(sharedCtx *SharedContext) error

Execute runs the install command logic

func (*InstallCommand) ExecuteOperation

func (c *InstallCommand) ExecuteOperation(ctx *SharedContext, sources []config.Source) error

ExecuteOperation implements CommandExecutor interface for install operations

func (*InstallCommand) GetCompletionMessage

func (c *InstallCommand) GetCompletionMessage() string

GetCompletionMessage implements CommandExecutor interface

func (*InstallCommand) GetOperationName

func (c *InstallCommand) GetOperationName() string

GetOperationName implements CommandExecutor interface

func (*InstallCommand) Name

func (c *InstallCommand) Name() string

Name returns the command name

func (*InstallCommand) ShouldContinueOnError

func (c *InstallCommand) ShouldContinueOnError(ctx *SharedContext) bool

ShouldContinueOnError implements CommandExecutor interface

type ListCommand

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

ListCommand implements the list command functionality

func NewListCommand

func NewListCommand() *ListCommand

NewListCommand creates a new list command instance

func (*ListCommand) CreateCommand

func (c *ListCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for list functionality

func (*ListCommand) Description

func (c *ListCommand) Description() string

Description returns the command description

func (*ListCommand) Execute

func (c *ListCommand) Execute(sharedCtx *SharedContext) error

Execute runs the list command logic

func (*ListCommand) Name

func (c *ListCommand) Name() string

Name returns the command name

type QueryCommand

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

QueryCommand implements enhanced query functionality with regex and multi-field search

func NewQueryCommand

func NewQueryCommand() *QueryCommand

NewQueryCommand creates a new query command instance

func (*QueryCommand) CreateCommand

func (c *QueryCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for query functionality

func (*QueryCommand) Description

func (c *QueryCommand) Description() string

Description returns the command description

func (*QueryCommand) Execute

func (c *QueryCommand) Execute(sharedCtx *SharedContext) error

Execute runs the query command logic

func (*QueryCommand) Name

func (c *QueryCommand) Name() string

Name returns the command name

type SharedContext

type SharedContext struct {
	Options *SharedOptions
	Config  *config.Config
	PM      *progress.Manager
}

SharedContext provides shared dependencies and helpers for commands

func NewSharedContext

func NewSharedContext(opts *SharedOptions) *SharedContext

NewSharedContext creates a new shared context for commands

func (*SharedContext) CreateInstaller

func (sc *SharedContext) CreateInstaller() (*installer.Installer, error)

CreateInstaller creates a new installer with the current configuration and options

func (*SharedContext) CreateQueryEngine

func (sc *SharedContext) CreateQueryEngine() (*engine.Engine, error)

CreateQueryEngine creates and initializes a query engine

func (*SharedContext) FilterEnabledSources

func (sc *SharedContext) FilterEnabledSources(sourceName string) ([]config.Source, error)

FilterEnabledSources filters sources to only enabled ones, optionally filtered by name

func (*SharedContext) GetAgentsDirectory

func (sc *SharedContext) GetAgentsDirectory() string

GetAgentsDirectory returns the base directory where agents are installed

func (*SharedContext) GetSourceByName

func (sc *SharedContext) GetSourceByName(sourceName string) (*config.Source, error)

GetSourceByName finds a source configuration by name

func (*SharedContext) LoadConfig

func (sc *SharedContext) LoadConfig() error

LoadConfig loads and validates the configuration file with progress indication

type SharedOptions

type SharedOptions struct {
	ConfigFile string
	Verbose    bool
	DryRun     bool
	NoColor    bool
	NoProgress bool
}

SharedOptions holds common configuration options used across commands

type ShowCommand

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

ShowCommand implements the show command functionality

func NewShowCommand

func NewShowCommand() *ShowCommand

NewShowCommand creates a new show command instance

func (*ShowCommand) CreateCommand

func (c *ShowCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for show functionality

func (*ShowCommand) Description

func (c *ShowCommand) Description() string

Description returns the command description

func (*ShowCommand) Execute

func (c *ShowCommand) Execute(sharedCtx *SharedContext) error

Execute runs the show command logic

func (*ShowCommand) Name

func (c *ShowCommand) Name() string

Name returns the command name

type StatsCommand

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

StatsCommand implements the stats command functionality

func NewStatsCommand

func NewStatsCommand() *StatsCommand

NewStatsCommand creates a new stats command instance

func (*StatsCommand) CreateCommand

func (c *StatsCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for stats functionality

func (*StatsCommand) Description

func (c *StatsCommand) Description() string

Description returns the command description

func (*StatsCommand) Execute

func (c *StatsCommand) Execute(sharedCtx *SharedContext) error

Execute runs the stats command logic

func (*StatsCommand) Name

func (c *StatsCommand) Name() string

Name returns the command name

type UninstallCommand

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

UninstallCommand implements the uninstall command functionality

func NewUninstallCommand

func NewUninstallCommand() *UninstallCommand

NewUninstallCommand creates a new uninstall command instance

func (*UninstallCommand) CreateCommand

func (c *UninstallCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for uninstall functionality

func (*UninstallCommand) Description

func (c *UninstallCommand) Description() string

Description returns the command description

func (*UninstallCommand) Execute

func (c *UninstallCommand) Execute(sharedCtx *SharedContext) error

Execute runs the uninstall command logic

func (*UninstallCommand) Name

func (c *UninstallCommand) Name() string

Name returns the command name

type UpdateCommand

type UpdateCommand struct {
	*BaseCommand
	// contains filtered or unexported fields
}

UpdateCommand implements the update command functionality

func NewUpdateCommand

func NewUpdateCommand() *UpdateCommand

NewUpdateCommand creates a new update command instance

func (*UpdateCommand) CreateCommand

func (c *UpdateCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for update functionality

func (*UpdateCommand) Description

func (c *UpdateCommand) Description() string

Description returns the command description

func (*UpdateCommand) Execute

func (c *UpdateCommand) Execute(sharedCtx *SharedContext) error

Execute runs the update command logic

func (*UpdateCommand) ExecuteOperation

func (c *UpdateCommand) ExecuteOperation(ctx *SharedContext, sources []config.Source) error

ExecuteOperation implements CommandExecutor interface for update operations

func (*UpdateCommand) GetCompletionMessage

func (c *UpdateCommand) GetCompletionMessage() string

GetCompletionMessage implements CommandExecutor interface

func (*UpdateCommand) GetOperationName

func (c *UpdateCommand) GetOperationName() string

GetOperationName implements CommandExecutor interface

func (*UpdateCommand) Name

func (c *UpdateCommand) Name() string

Name returns the command name

func (*UpdateCommand) ShouldContinueOnError

func (c *UpdateCommand) ShouldContinueOnError(ctx *SharedContext) bool

ShouldContinueOnError implements CommandExecutor interface

type ValidateCommand

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

ValidateCommand implements the validate command functionality

func NewValidateCommand

func NewValidateCommand() *ValidateCommand

NewValidateCommand creates a new validate command instance

func (*ValidateCommand) CreateCommand

func (c *ValidateCommand) CreateCommand(sharedCtx *SharedContext) *cobra.Command

CreateCommand creates the cobra command for validate functionality

func (*ValidateCommand) Description

func (c *ValidateCommand) Description() string

Description returns the command description

func (*ValidateCommand) Execute

func (c *ValidateCommand) Execute(sharedCtx *SharedContext) error

Execute runs the validate command logic

func (*ValidateCommand) Name

func (c *ValidateCommand) Name() string

Name returns the command name

Jump to

Keyboard shortcuts

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