-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
It's easy to build out a command structure to get a CLI app up and going fairly quickly (thank you!).
That said, once I've modeled the command structure in code, I'd like to be able to access a representation of what's been set up. Something that exposes the command structure (possibly as a set of nested structs?).
My end goal is to be able to take this exposed model and do things like generate Bash/Zsh/Fish/Powershell auto-completion scripts. By opening this up, it would make it easier for other packages to integrate features of this type.
I haven't yet dug into the code enough to fully understand the internals, but it looks like it would start with exposing the model for Cmd.commands[].
Lines 127 to 141 in fbc50e9
| func (c *Cmd) Command(name, desc string, init CmdInitializer) { | |
| aliases := strings.Fields(name) | |
| c.commands = append(c.commands, &Cmd{ | |
| ErrorHandling: c.ErrorHandling, | |
| name: aliases[0], | |
| aliases: aliases, | |
| desc: desc, | |
| init: init, | |
| commands: []*Cmd{}, | |
| options: []*container.Container{}, | |
| optionsIdx: map[string]*container.Container{}, | |
| args: []*container.Container{}, | |
| argsIdx: map[string]*container.Container{}, | |
| }) | |
| } |
jrarmstro, mattolenik, davegallant, wkhere and curio77
Metadata
Metadata
Assignees
Labels
No labels