Add an "embed" tag.

This commit is contained in:
Alec Thomas
2018-09-19 13:23:18 +10:00
parent 0ba159f97d
commit 54338bd8b1
5 changed files with 31 additions and 1 deletions
+16
View File
@@ -626,3 +626,19 @@ func TestExcludedField(t *testing.T) {
_, err = p.Parse([]string{"--excluded=foo"})
require.Error(t, err)
}
func TestUnnamedFieldEmbeds(t *testing.T) {
type Embed struct {
Flag string
}
var cli struct {
One Embed `prefix:"one-" embed:""`
Two Embed `prefix:"two-" embed:""`
}
buf := &strings.Builder{}
p := mustNew(t, &cli, kong.Writers(buf, buf), kong.Exit(func(int) {}))
_, err := p.Parse([]string{"--help"})
require.NoError(t, err)
require.Contains(t, buf.String(), `--one-flag=STRING`)
require.Contains(t, buf.String(), `--two-flag=STRING`)
}