FIx: Allow ext flags to be opt-out by default rather than opt-in

This commit is contained in:
Naveen Gogineni
2022-11-01 17:44:12 -04:00
parent ae8d932413
commit fb3a9cebb4
4 changed files with 41 additions and 7 deletions

View File

@@ -654,6 +654,7 @@ func TestApp_FlagsFromExtPackage(t *testing.T) {
}()
a := &App{
AllowExtFlags: true,
Flags: []Flag{
&StringFlag{
Name: "carly",
@@ -677,6 +678,28 @@ func TestApp_FlagsFromExtPackage(t *testing.T) {
if someint != 10 {
t.Errorf("Expected 10 got %d for someint", someint)
}
a = &App{
Flags: []Flag{
&StringFlag{
Name: "carly",
Aliases: []string{"c"},
Required: false,
},
&BoolFlag{
Name: "jimbob",
Aliases: []string{"j"},
Required: false,
Value: true,
},
},
}
// this should return an error since epflag shouldnt be registered
err = a.Run([]string{"foo", "-c", "cly", "--epflag", "10"})
if err == nil {
t.Error("Expected error")
}
}
func TestApp_Setup_defaultsReader(t *testing.T) {