1d00dfef7b
This includes branching arguments as well as commands, eg.
app user create <id> <first> <last>
app user <id> delete
app user <id> rename <to>
Of note, required/optional flags and positional arguments are not
currently enforced.
45 lines
652 B
Go
45 lines
652 B
Go
package kong
|
|
|
|
import "reflect"
|
|
|
|
type Application = Node
|
|
|
|
// A Branch is a command or positional argument that results in a branch in the command tree.
|
|
type Branch struct {
|
|
Command *Command
|
|
Argument *Argument
|
|
}
|
|
|
|
type Command = Node
|
|
|
|
type Node struct {
|
|
Name string
|
|
Help string
|
|
Flags []*Flag
|
|
Positional []*Value
|
|
Children []*Branch
|
|
}
|
|
|
|
type Value struct {
|
|
Name string
|
|
Help string
|
|
Decoder Decoder
|
|
Value reflect.Value
|
|
Required bool
|
|
}
|
|
|
|
type Positional = Value
|
|
|
|
type Argument struct {
|
|
Node
|
|
Argument *Value
|
|
}
|
|
|
|
type Flag struct {
|
|
Value
|
|
Placeholder string
|
|
Env string
|
|
Short rune
|
|
Default string
|
|
}
|