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

Optional exit code support #361

Merged
merged 27 commits into from
Apr 30, 2016
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9c0db3f
Created types for functions
txgruppi Jul 28, 2015
49c1229
Added exit code support
txgruppi Jul 28, 2015
b79f884
Updated README.md with exit code sample
txgruppi Jul 28, 2015
1510d7e
Updated tests to support exit code
txgruppi Jul 28, 2015
10c8309
Merge branch 'develop' of https://github.com/txgruppi/cli into txgrup…
meatballhat Apr 25, 2016
a17c8cf
Rename func type suffixes `Fn`->`Func` and add `OnUsageErrorFunc`
meatballhat Apr 25, 2016
b40b627
Ensure README examples are runnable
meatballhat Apr 26, 2016
b7329f4
Switch from multi-return with exit codes to ExitCoder check
meatballhat Apr 27, 2016
f3e55a0
Move error types to errors.go
meatballhat Apr 27, 2016
f688d47
Encapsulate ExitCoder check into a lil func
meatballhat Apr 27, 2016
882dd2c
Making sure examples in README are valid
meatballhat Apr 27, 2016
23c7b80
Merge remote-tracking branch 'origin/master' into txgruppi-develop
meatballhat Apr 27, 2016
b2ac061
TRIVIAL Remove trailing whitespace
meatballhat Apr 27, 2016
d48e22a
Docs around exit error behavior, + handling MultiError in HandleExitC…
meatballhat Apr 27, 2016
d45f7c1
Allow for legacy and newer Action func signatures
meatballhat Apr 27, 2016
3b5133f
Add gfmxr integration for checking examples in README.md
meatballhat Apr 27, 2016
9e8ead5
Making gfmxr assertion stronger
meatballhat Apr 27, 2016
0292429
Removing unused vars
meatballhat Apr 27, 2016
7371138
Add back App.RunAndExitOnError with deprecation message
meatballhat Apr 27, 2016
271b56c
Cleanups based on feedback in #361
meatballhat Apr 28, 2016
b453bf5
Clarifying errors returned from HandleAction + tests
meatballhat Apr 28, 2016
c3a6370
Moving remaining details from #361 description to CHANGELOG.md
meatballhat Apr 28, 2016
7651aa0
TRIVIAL specify *return* signature in deprecation message
meatballhat Apr 28, 2016
6eb8c82
Merge remote-tracking branch 'origin/master' into txgruppi-develop
meatballhat Apr 28, 2016
61d4175
Merge remote-tracking branch 'origin/master' into txgruppi-develop
meatballhat Apr 28, 2016
4cae17c
Ensure MultiError returned when both Before and After funcs given
meatballhat Apr 28, 2016
06c01a4
A few tweaks based on feedback in #361
meatballhat Apr 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
var (
appActionDeprecationURL = "https://github.com/codegangsta/cli/blob/master/CHANGELOG.md#deprecated-cli-app-action-signature"

contactSysadmin = "This is an error in the application. Please contact the distributor of this application if this is not you."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏


errNonFuncAction = NewExitError("ERROR invalid Action type. "+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the addition of the hyperlink, but I still think it'd be nice to include something like: This is an error in the application, please contact the distributor of this application if this is not you just in case I, as a non-programmer, install a program using codegangsta/cli and receive this error message.

Harkening back to Please contact your system administrator which was always amusing when that was indeed you.

"Must be a func of type `cli.ActionFunc`. "+
fmt.Sprintf("Must be a func of type `cli.ActionFunc`. %s", contactSysadmin)+
fmt.Sprintf("See %s", appActionDeprecationURL), 2)
errInvalidActionSignature = NewExitError("ERROR invalid Action signature. "+
"Must be `cli.ActionFunc`. "+
fmt.Sprintf("Must be `cli.ActionFunc`. %s", contactSysadmin)+
fmt.Sprintf("See %s", appActionDeprecationURL), 2)
)

Expand Down Expand Up @@ -419,7 +421,7 @@ func HandleAction(action interface{}, context *Context) (err error) {
if len(vals) == 0 {
fmt.Fprintln(os.Stderr,
"DEPRECATED Action signature. Must be `cli.ActionFunc`")
return err
return nil
}

if len(vals) > 1 {
Expand Down