Fix:(issue_1455) Allow bool flags from input altsrc

This commit is contained in:
Naveen Gogineni
2022-08-16 18:34:34 -04:00
committed by Dan Buch
parent 42eb492258
commit 78dac9c7af
5 changed files with 30 additions and 19 deletions

View File

@@ -11,7 +11,7 @@ import (
const (
fileName = "current.json"
simpleJSON = `{"test": 15}`
simpleJSON = `{"test": 15, "testb": false}`
nestedJSON = `{"top": {"test": 15}}`
)
@@ -34,11 +34,16 @@ func TestCommandJSONFileTest(t *testing.T) {
Action: func(c *cli.Context) error {
val := c.Int("test")
expect(t, val, 15)
valb := c.Bool("testb")
expect(t, valb, false)
return nil
},
Flags: []cli.Flag{
NewIntFlag(&cli.IntFlag{Name: "test"}),
&cli.StringFlag{Name: "load"}},
&cli.StringFlag{Name: "load"},
NewBoolFlag(&cli.BoolFlag{Name: "testb", Value: true}),
},
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))
err := command.Run(c)