fdc7230e22
This allows help to be called even when the parse trace is invalid. Without this, the command-line would have to be valid in order to use help at all, which defeats the purpose.
28 lines
506 B
Go
28 lines
506 B
Go
package kong
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestModelApplicationCommands(t *testing.T) {
|
|
var cli struct {
|
|
One struct {
|
|
Two struct {
|
|
} `kong:"cmd"`
|
|
Three struct {
|
|
Four struct {
|
|
Four string `kong:"arg"`
|
|
} `kong:"arg"`
|
|
} `kong:"cmd"`
|
|
} `kong:"cmd"`
|
|
}
|
|
p := mustNew(t, &cli)
|
|
actual := []string{}
|
|
for _, cmd := range p.Leaves() {
|
|
actual = append(actual, cmd.Path())
|
|
}
|
|
require.Equal(t, []string{"one two", "one three <four>"}, actual)
|
|
}
|