@@ -55,6 +55,49 @@ func TestDynamic(t *testing.T) {
5555 require .Equal (t , map [string ]string {"bar" : "yuh" }, s .Foo )
5656 },
5757 },
58+ {
59+ name : "dynamic with an array" ,
60+ test : func (t * testing.T ) {
61+ s := & struct {
62+ Foo map [string ]map [string ][]string
63+ }{}
64+ c := newCmd ([]string {"--foo[0]-bar" , "a b c" }, & s )
65+ c .Flags ().DynamicStringSlice ("foo[<key>]-bar" , false , cli.FlagDoc {})
66+ err := c .Execute ()
67+ require .NoError (t , err )
68+ require .Equal (t , map [string ]map [string ][]string {
69+ "[0]" : {"bar" : []string {"a" , "b" , "c" }},
70+ }, s .Foo )
71+ },
72+ },
73+ {
74+ name : "dynamic with an array and explode" ,
75+ test : func (t * testing.T ) {
76+ s := & struct {
77+ Foo map [string ]map [string ][]string
78+ }{}
79+ c := newCmd ([]string {"--foo[0]-bar" , "a" , "--foo[0]-bar" , "b" }, & s )
80+ c .Flags ().DynamicStringSlice ("foo[<key>]-bar" , true , cli.FlagDoc {})
81+ err := c .Execute ()
82+ require .NoError (t , err )
83+ require .Equal (t , map [string ]map [string ][]string {
84+ "[0]" : {"bar" : []string {"a" , "b" }},
85+ }, s .Foo )
86+ },
87+ },
88+ {
89+ name : "int" ,
90+ test : func (t * testing.T ) {
91+ s := & struct {
92+ Foo []int
93+ }{}
94+ c := newCmd ([]string {"--foo[0]" , "12" }, & s )
95+ c .Flags ().DynamicInt ("foo[<index>]" , cli.FlagDoc {})
96+ err := c .Execute ()
97+ require .NoError (t , err )
98+ require .Equal (t , []int {12 }, s .Foo )
99+ },
100+ },
58101 }
59102
60103 for _ , tc := range testcases {
0 commit comments