Ignore fields tagged with kong:"-".

This commit is contained in:
Alec Thomas
2018-09-17 10:25:35 +10:00
parent 9cbf4a5d4b
commit 467352418f
3 changed files with 25 additions and 5 deletions
+13
View File
@@ -613,3 +613,16 @@ func TestEmbedInterface(t *testing.T) {
require.Equal(t, "foo", cli.SomeFlag)
require.Equal(t, "yes", cli.TestInterface.(*TestImpl).Flag)
}
func TestExcludedField(t *testing.T) {
var cli struct {
Flag string
Excluded string `kong:"-"`
}
p := mustNew(t, &cli)
_, err := p.Parse([]string{"--flag=foo"})
require.NoError(t, err)
_, err = p.Parse([]string{"--excluded=foo"})
require.Error(t, err)
}