Allow parent flags to be processed #4

This commit is contained in:
Gerald Kaszuba
2018-05-19 13:58:35 +10:00
committed by Alec Thomas
parent 3b21a54094
commit a9179cd8ec
3 changed files with 26 additions and 8 deletions
+16
View File
@@ -134,3 +134,19 @@ func TestCantMixPositionalAndBranches(t *testing.T) {
_, err := New(&cli)
require.Error(t, err)
}
func TestPropagatedFlags(t *testing.T) {
var cli struct {
Flag1 string
Command1 struct {
Flag2 bool
Command2 struct{} `cmd:""`
} `cmd:""`
}
parser := mustNew(t, &cli)
_, err := parser.Parse([]string{"command-1", "command-2", "--flag-2", "--flag-1=moo"})
require.NoError(t, err)
require.Equal(t, "moo", cli.Flag1)
require.Equal(t, true, cli.Command1.Flag2)
}