Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding WroteHelp() helper #263

Merged
merged 1 commit into from
Sep 23, 2018
Merged

Adding WroteHelp() helper #263

merged 1 commit into from
Sep 23, 2018

Conversation

iamgnat
Copy link

@iamgnat iamgnat commented Jun 21, 2018

Adding a helper function to simplify the Parse*() caller determining if the help text was written or not.

Usage would look like:

...
_, err := flags.Parse(opts)
if flags.WroteHelp(err) {
    os.Exit(0)
}
if err != nil {
    ...
}
...

Test output:

$ go test -v -run TestWroteHelp
=== RUN   TestWroteHelp
=== RUN   TestWroteHelp/No_error
=== RUN   TestWroteHelp/Plain_error
=== RUN   TestWroteHelp/ErrUnknown
=== RUN   TestWroteHelp/ErrHelp
--- PASS: TestWroteHelp (0.00s)
    --- PASS: TestWroteHelp/No_error (0.00s)
    --- PASS: TestWroteHelp/Plain_error (0.00s)
    --- PASS: TestWroteHelp/ErrUnknown (0.00s)
    --- PASS: TestWroteHelp/ErrHelp (0.00s)
PASS
ok  	github.com/jessevdk/go-flags	0.002s

@iamgnat
Copy link
Author

iamgnat commented Jun 29, 2018

@jessevdk Can I please have a review of this PR?

@jessevdk jessevdk merged commit 3beeeb6 into jessevdk:master Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants