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

Make error message for bad options more descriptive. #601

Closed
ntc2 opened this issue Jul 15, 2015 · 3 comments
Closed

Make error message for bad options more descriptive. #601

ntc2 opened this issue Jul 15, 2015 · 3 comments

Comments

@ntc2
Copy link
Contributor

ntc2 commented Jul 15, 2015

If I give a bad option or combination of options to stack it just prints the usage, without telling me what the problem is. It should tell me what it doesn't like about my options.

For example, I'm trying to figure out the stack test equivalent of cabal test --test-option=<op1> --test-option=<op2>. Looking at stack test --help I see the --test-arguments option. First I try

stack test --test-argument=<op1> --test-argument=<op2>

and stack prints a generic Usage: ... message without any hint about what is wrong.

The problem is that the option is called --test-arguments (plural), not --test-argument (singular); Stack should tell me what the problem is: the option I gave is unknown (bonus points for suggesting the correct option like GHC does with typoed symbols, but that's a fancier fix).

I then wonder if I'm only allowed to use the --test-argument option once and try

stack test --test-argument=<op1>

and stack says Usage: .... Again, I have no idea what I've done wrong.

I then realize I was supposed to write --test-arguments, plural, so I try

stack test --test-arguments=<op1>

which works. So, I try two arguments again with

stack test --test-arguments=<op1> --test-arguments=<op2>

and stack says Usage: .... The problem now is that I'm not allowed to specify --test-arguments twice; Stack should tell me this.

Finally, I try the correct

stack test --test-arguments='<op1> <op2>'

and the test runs :)

@borsboom
Copy link
Contributor

Some of this is because stack isn't consistent about how it handles certain kinds of arguments (just opened #652 about this), some is because of the way we use optparse-applicative, and some comes down to limitations in optparse-applicative that may be more difficult to overcome. I've created a new milestone to group all the options parsing-related issues together.

@borsboom borsboom added this to the Options parsing milestone Jul 21, 2015
@borsboom borsboom modified the milestones: Options parsing, P3 Sep 12, 2015
@borsboom borsboom modified the milestones: P2: Should, P3: Optional Oct 31, 2015
@borsboom
Copy link
Contributor

borsboom commented Jan 6, 2016

@drwebb I've bumped stack to use LTS 4, which means optparse-applicative-0.12 is now available, in case that helps with this.

@snoyberg
Copy link
Contributor

In recent Stacks I get a "invalid option" message, which seems to resolve this issue. If there's still a problem, please comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants