FIx: Allow ext flags to be opt-out by default rather than opt-in
This commit is contained in:
19
app.go
19
app.go
@@ -113,6 +113,9 @@ type App struct {
|
||||
UseShortOptionHandling bool
|
||||
// Enable suggestions for commands and flags
|
||||
Suggest bool
|
||||
// Allows global flags set by libraries which use flag.XXXVar(...) directly
|
||||
// to be parsed through this library
|
||||
AllowExtFlags bool
|
||||
|
||||
didSetup bool
|
||||
|
||||
@@ -199,13 +202,15 @@ func (a *App) Setup() {
|
||||
a.ErrWriter = os.Stderr
|
||||
}
|
||||
|
||||
// add global flags added by other packages
|
||||
flag.VisitAll(func(f *flag.Flag) {
|
||||
// skip test flags
|
||||
if !strings.HasPrefix(f.Name, ignoreFlagPrefix) {
|
||||
a.Flags = append(a.Flags, &extFlag{f})
|
||||
}
|
||||
})
|
||||
if a.AllowExtFlags {
|
||||
// add global flags added by other packages
|
||||
flag.VisitAll(func(f *flag.Flag) {
|
||||
// skip test flags
|
||||
if !strings.HasPrefix(f.Name, ignoreFlagPrefix) {
|
||||
a.Flags = append(a.Flags, &extFlag{f})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var newCommands []*Command
|
||||
|
||||
|
Reference in New Issue
Block a user