Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseStruct ¶ added in v2.0.4
func ParseStruct(node *CommandNode, val reflect.Value) error
ParseStruct recursively parses the struct fields to build the command tree.
Example:
node := parser.NewCommandNode("init", "Initialize project", reflect.ValueOf(&InitCmd{}))
val := reflect.ValueOf(&InitCmd{})
err := parser.ParseStruct(node, val)
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{}))
Click to show internal directories.
Click to hide internal directories.