Skip to content

Commit

Permalink
Merge pull request #29 from clagraff/develop
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
clagraff committed Nov 7, 2016
2 parents 1d7359d + f58397c commit 7834d19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Upcoming

# v1.0.1
## Bug Fixes
- Added missing return after executing callback for options.
- Fixed conditions where the callback is not called if an error occurred.
19 changes: 10 additions & 9 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func (p *Parser) Parse(allArgs ...string) {

if usedParser != true {
p.Callback(p, p.Namespace, nil, MissingParserErr{p.Parsers})
return
}
}

Expand All @@ -326,12 +327,12 @@ func (p *Parser) Parse(allArgs ...string) {

if option == nil {
p.Callback(p, p.Namespace, args, InvalidOptionErr{optionName})
return
}

args, err = option.DesiredAction(p, option, args...)
if err != nil {
p.Callback(p, p.Namespace, args, err)
}
p.Callback(p, p.Namespace, args, err)
return
}

if len(args) > 0 {
Expand All @@ -340,9 +341,8 @@ func (p *Parser) Parse(allArgs ...string) {
delete(requiredOptions, opt.DisplayName())
}
_, err := opt.DesiredAction(p, opt, args...)
if err != nil {
p.Callback(p, p.Namespace, args, err)
}
p.Callback(p, p.Namespace, args, err)
return
}
}

Expand All @@ -354,17 +354,18 @@ func (p *Parser) Parse(allArgs ...string) {
delete(requiredOptions, f.DestName)
}
args, err = f.DesiredAction(p, f, args...)
if err != nil {
p.Callback(p, p.Namespace, args, err)
}
p.Callback(p, p.Namespace, args, err)
return
}

if len(requiredOptions) != 0 {
for _, option := range requiredOptions {
p.Callback(p, p.Namespace, args, MissingOptionErr{option.DisplayName()})
return
}
}
p.Callback(p, p.Namespace, args, nil)
return
}

// Path will set the parser's program name to the program name specified by the
Expand Down

0 comments on commit 7834d19

Please sign in to comment.