Add sub commands 3 levels deep

This commit is contained in:
sophia 2021-04-26 12:34:06 -05:00 committed by Paul Hinze
parent de649b2154
commit c6ad026070
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -17,6 +17,13 @@ func (c *Command) ExecuteFunc(cliArgs []string) interface{} {
}
switch cliArgs[1] {
case "info":
if len(cliArgs) < 3 {
return c.ExecuteInfo
}
switch cliArgs[2] {
case "ofni":
return c.ExecuteOfni
}
return c.ExecuteInfo
case "dothing":
return c.ExecuteThing
@ -47,6 +54,14 @@ func (c *Command) CommandInfo() *component.CommandInfo {
Help: "Shows info",
Synopsis: "IT. SHOWS. INFO.",
Flags: []*option.Option{},
Subcommands: []*component.CommandInfo{
&component.CommandInfo{
Name: "ofni",
Help: "Shows ofni",
Synopsis: "BIZZARO info",
Flags: []*option.Option{},
},
},
},
&component.CommandInfo{
Name: "dothing",
@ -100,3 +115,8 @@ func (c *Command) ExecuteInfo(trm terminal.UI, env plugincore.Project) int64 {
return 0
}
func (c *Command) ExecuteOfni(trm terminal.UI) int64 {
trm.Output("I am bizzaro info! Call me ofni")
return 0
}