base

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCommand

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

BaseCommand provides common functionality for commands

func NewBaseCommand

func NewBaseCommand(name, description, usage string) *BaseCommand

NewBaseCommand creates a new base command

func (*BaseCommand) Description

func (c *BaseCommand) Description() string

Description returns the command description

func (*BaseCommand) Name

func (c *BaseCommand) Name() string

Name returns the command name

func (*BaseCommand) Usage

func (c *BaseCommand) Usage() string

Usage returns command usage instructions

type Command

type Command interface {
	// Execute runs the command with the given arguments
	Execute(ctx context.Context, args []string) error
	// Name returns the name of the command
	Name() string
	// Description returns a brief description of what the command does
	Description() string
	// Usage returns detailed usage instructions
	Usage() string
}

Command represents a CLI command that can be executed

type Registry

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

Registry manages the 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) error

Execute runs a command by name with the given arguments

func (*Registry) Get

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

Get returns a command by name

func (*Registry) Help

func (r *Registry) Help(name string) string

Help returns detailed help for a specific command

func (*Registry) ListCommands

func (r *Registry) ListCommands() string

ListCommands returns a sorted list of available commands with their descriptions

func (*Registry) Register

func (r *Registry) Register(cmd Command)

Register adds a command to the registry

Jump to

Keyboard shortcuts

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