If I have a CLI with sub commands, it is not possible to call the root comand, even if Run() is defined at the root.
For example:
type CLI struct {
SubCmd1 SubCmd1 `cmd:""`
SubCmd2 SubCmd2 `cmd:""`
}
func (cli *CLI) Run() error {
fmt.Println("This is the root command")
return nil
}
type SubCmd1 struct {}
func (c *SubCmd1) Run() error {
fmt.Println("This is sub command 1")
return nil
}
type SubCmd2 struct {}
func (c *SubCmd3) Run() error {
fmt.Println("This is sub command 3")
return nil
}
func main() {
var cli CLI
ctx := kong.Parse(&cli)
err := ctx.Run()
ctx.FatalIfErrorf(err)
}
Upon compiling, it is not possible to call ./myapp as it will return the following error: myapp: error: expected one of "sub-cmd1", "sub-cmd2". I would love to have the ability to call Run() on the root: ./myapp as well as the sub commands: ./myapp sub-cmd1.
If I have a CLI with sub commands, it is not possible to call the root comand, even if
Run()is defined at the root.For example:
Upon compiling, it is not possible to call
./myappas it will return the following error:myapp: error: expected one of "sub-cmd1", "sub-cmd2". I would love to have the ability to callRun()on the root:./myappas well as the sub commands:./myapp sub-cmd1.