Files
kong/model_test.go
T
Alec Thomas fdc7230e22 Separate validation into a distinct step.
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.
2018-05-31 15:20:45 +10:00

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)
}