Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgMetadata ¶
ArgMetadata holds information about a positional argument.
type CommandNode ¶
type CommandNode struct {
Name string
Description string
Aliases []string
Flags map[string]*FlagMetadata
ShortFlags map[string]string // Maps short name to full name
Args []*ArgMetadata
Children map[string]*CommandNode
Value reflect.Value
Type reflect.Type
}
CommandNode represents a node in the command tree.
func NewCommandNode ¶
func NewCommandNode(name, description string, val reflect.Value) *CommandNode
NewCommandNode creates a new CommandNode with initialized maps.
Example:
node := parser.NewCommandNode("init", "Initialize project", reflect.ValueOf(&InitCmd{}))
func Parse ¶
func Parse(root any) (*CommandNode, error)
Parse parses a struct and returns a CommandNode tree.
Example:
type CLI struct {
Serve ServeCmd `cmd:"serve"`
}
node, err := parser.Parse(&CLI{})
Click to show internal directories.
Click to hide internal directories.