help

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindCommandSuggestions

func FindCommandSuggestions(partial string) []string

FindCommandSuggestions returns command suggestions for a partial input

func FindSubCommandSuggestions

func FindSubCommandSuggestions(cmdPath []string, partial string) []string

FindSubCommandSuggestions returns subcommand suggestions for a command and partial input

func GetCLIHelp

func GetCLIHelp(args []string) string

GetCLIHelp returns formatted help text for CLI usage

func GetHelpText

func GetHelpText(formatter Formatter, args []string) string

GetHelpText returns formatted help text using the specified formatter

func InitCommands

func InitCommands()

InitCommands initializes the default command registry with all commands

Types

type CLIFormatter

type CLIFormatter struct {
	IndentWidth int
}

CLIFormatter formats help text for command line usage

func NewCLIFormatter

func NewCLIFormatter() *CLIFormatter

NewCLIFormatter creates a new CLI formatter

func (*CLIFormatter) FormatCommand

func (f *CLIFormatter) FormatCommand(cmd *CommandDescriptor) string

FormatCommand formats a command's help for CLI display

func (*CLIFormatter) FormatCommandList

func (f *CLIFormatter) FormatCommandList(cmds []*CommandDescriptor, header string) string

FormatCommandList formats a list of commands for CLI display

func (*CLIFormatter) FormatRootHelp

func (f *CLIFormatter) FormatRootHelp(registry *Registry) string

FormatRootHelp formats the root help display

type CommandDescriptor

type CommandDescriptor struct {
	Name        string
	Aliases     []string
	Description string
	Usage       string
	Examples    []string
	SubCommands []*CommandDescriptor
	ParentCmd   *CommandDescriptor // Reference to parent for navigation
}

CommandDescriptor defines the structure for a command and its help information

func GetHelpForCommand

func GetHelpForCommand(args []string) *CommandDescriptor

GetHelpForCommand returns the command descriptor for a given command path

func (*CommandDescriptor) AddSubCommand

func (cmd *CommandDescriptor) AddSubCommand(sub *CommandDescriptor)

AddSubCommand adds a subcommand to a command

func (*CommandDescriptor) FindSubCommand

func (cmd *CommandDescriptor) FindSubCommand(name string) *CommandDescriptor

FindSubCommand looks up a subcommand by name or alias

type Formatter

type Formatter interface {
	// FormatCommand returns formatted help text for a command
	FormatCommand(cmd *CommandDescriptor) string

	// FormatCommandList returns formatted help text for a list of commands
	FormatCommandList(cmds []*CommandDescriptor, header string) string

	// FormatRootHelp returns formatted help text for the root level
	FormatRootHelp(registry *Registry) string
}

Formatter defines the interface for formatting help text

type Registry

type Registry struct {
	Commands []*CommandDescriptor
}

Registry maintains a collection of all top-level commands

var DefaultRegistry *Registry

DefaultRegistry contains the default command registry for the application

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new command registry

func (*Registry) AddCommand

func (r *Registry) AddCommand(cmd *CommandDescriptor)

AddCommand adds a top-level command to the registry

func (*Registry) FindCommand

func (r *Registry) FindCommand(name string) *CommandDescriptor

FindCommand looks up a command by name or alias

Jump to

Keyboard shortcuts

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