Skip to content

Commit

Permalink
Fix setDefaults to exit early on --help
Browse files Browse the repository at this point in the history
When `--help` is passed, there is no need to set and validate default
flags/arguments, since we are just going to print the usage text and
exit.

This fixes #218.
  • Loading branch information
Andrew Mason authored and alecthomas committed Dec 3, 2017
1 parent fde80b5 commit 7e2d128
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app.go
Expand Up @@ -402,6 +402,9 @@ func (a *Application) setDefaults(context *ParseContext) error {
flagElements := map[string]*ParseElement{}
for _, element := range context.Elements {
if flag, ok := element.Clause.(*FlagClause); ok {
if flag.name == "help" {
return nil
}
flagElements[flag.name] = element
}
}
Expand Down

0 comments on commit 7e2d128

Please sign in to comment.