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

Interface enhancements for cake (#1862) #1866

Merged
merged 6 commits into from
Nov 14, 2011
Merged

Interface enhancements for cake (#1862) #1866

merged 6 commits into from
Nov 14, 2011

Conversation

TrevorBurnham
Copy link
Collaborator

On the current master, while using an invalid task name produces a simple message, an invalid option (flag) produces a stack trace, because the exception thrown by OptionParser isn't caught (#1862). This pull request corrects that, instead producing, for example:

> cake --help
No such option: "--help"

To see a list of all tasks/options, run "cake"

The other thing this patch does is preface the task list with a message like this:

Cakefile defines the following tasks:

This becomes useful when the relevant Cakefile is in a parent directory (feature introduced by #1687), as it will then say

../Cakefile defines the following tasks:

making things much easier for folks with a hierarchy of Cakefiles.

try
options = oparse.parse(args)
catch e
return badArgument "#{e}".match(/option: (.+)/)[1], "option"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like this. We can't just pass along the error given by OptionParser?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added a commit to do this, though with some hesitation. This produces the output

Error: unrecognized option: --help

instead of the simpler and more consistent

No such option: "--help"

@michaelficarra
Copy link
Collaborator

LGTM

@TrevorBurnham
Copy link
Collaborator Author

Cool, merging.

TrevorBurnham added a commit that referenced this pull request Nov 14, 2011
Interface enhancements for cake (#1862)
@TrevorBurnham TrevorBurnham merged commit 9e1d1f5 into jashkenas:master Nov 14, 2011
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