Documentation
¶
Index ¶
- func FindCommandSuggestions(partial string) []string
- func FindSubCommandSuggestions(cmdPath []string, partial string) []string
- func GetCLIHelp(args []string) string
- func GetHelpText(formatter Formatter, args []string) string
- func InitCommands()
- type CLIFormatter
- type CommandDescriptor
- type Formatter
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindCommandSuggestions ¶
FindCommandSuggestions returns command suggestions for a partial input
func FindSubCommandSuggestions ¶
FindSubCommandSuggestions returns subcommand suggestions for a command and partial input
func GetCLIHelp ¶
GetCLIHelp returns formatted help text for CLI usage
func GetHelpText ¶
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 (*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