basho / clique

CLI Framework for Erlang
Apache License 2.0
147 stars 49 forks source link

Enable custom return status codes #66

Closed nickelization closed 9 years ago

nickelization commented 9 years ago

This PR allows callbacks to specify custom status codes to be returned as a result of a Clique command being run.

These changes also allow existing callbacks to remain the same - triggering them will cause clique:run to just return 'ok' as before. Callbacks can now also specify custom exit status by returning {exit_status, Status, Result} instead of just Result, which will cause clique:run to return {error, ExitStatus} instead. Finally, internal Clique errors will (for now) default to returning an error code of 1.

This is technically a slight API change, insofar as that it is now possible for clique:run to return {error, StatusCode} as well as 'ok'. However, none of our existing code has a problem with this, so this would only potentially affect third-party code outside of Basho. For anyone who doesn't care about return codes, it's a very simple change to work around, and for someone who does care about return codes, this should be a welcome enhancement.

macintux commented 9 years ago

@nickelization Could you please edit the description rather than appending the edit in the middle? It's a bit confusing, so while I think I understand the full impact of the change + change to the change, it'd be useful to see it laid out as if you had made no changes along the way.

macintux commented 9 years ago

I'd really like to see a test involving a callback that returns an exit status before giving this a thumbs up.

nickelization commented 9 years ago

@macintux Thanks for the review comments! Replies below:

nickelization commented 9 years ago

Okay @macintux, review changes are in :). Anything else?

nickelization commented 9 years ago

@borshop merge