Add BoolTFlag type
Compared to BoolFlag type, BoolTFlag treats 'true' as the default value for the flag. Without it, we have to use --no-action flag if we set the action is done in default. But sometimes it is bad to maintain flags with negative meanings. And it will be painful if we change the default value for the flag. As this implementation, it keeps all existing functionality. So it is compatible with old versions.
This commit is contained in:
@@ -37,6 +37,13 @@ func TestContext_Bool(t *testing.T) {
|
||||
expect(t, c.Bool("myflag"), false)
|
||||
}
|
||||
|
||||
func TestContext_BoolT(t *testing.T) {
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Bool("myflag", true, "doc")
|
||||
c := cli.NewContext(nil, set, set)
|
||||
expect(t, c.BoolT("myflag"), true)
|
||||
}
|
||||
|
||||
func TestContext_Args(t *testing.T) {
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Bool("myflag", false, "doc")
|
||||
|
Reference in New Issue
Block a user