-
Notifications
You must be signed in to change notification settings - Fork 114
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
Specific error message #54
Comments
"Unknown option" errors should work already. If you have an example where they don't, please open a separate ticket. Some of the other errors can be manually specified by using a custom reader and the nullOption ( long "hello"
<> metavar "TARGET"
<> reader (\s -> msum
[ auto s
, readerError "expected int" ])
<> noArgError (ErrorMsg "missing int parameter") ) but I do agree that the defaults should be more informative. |
On Sat, 26 Oct 2013, Paolo Capriotti wrote:
I am refering to the example given in the docs: |
When running the example, I get:
Am I missing something? |
On Sat, 26 Oct 2013, Paolo Capriotti wrote:
I get the same result for this example. However, I don't want the general Also I tried "--hello" without an argument and I tried "--quiet" without |
Why not? If the user specified an invalid option, it is likely that they are confused about the available options, and the "usage" message can be helpful. I don't think it hurts either way. I guess I could add a preference to never display the usage message when a more specific error can be displayed, but I'd rather limit the number of such preferences. With the changes in the formatting branch, it should be relatively easy to use |
On Sat, 26 Oct 2013, Paolo Capriotti wrote:
In my experience it means that I have just mistyped an option or forgot
ok |
github has hidden my additional comment: On Sat, 26 Oct 2013, amigalemming wrote:
|
next attempt: Also I tried "--hello" without an argument and I tried "--quiet" without |
It should now be relatively easy to customise the appearance of the generated help text. For example, in #54, @amigalemming asks for a way to get rid of the usage line when a specific error message is displayed. This is now easy to achieve: exec :: ParserPrefs -> ParserInfo a -> IO a exec pprefs pinfo = do res <- execParserPure pprefs pinfo <$> getArgs let f h | isEmpty (helpError h) = h | otherwise = h { helpUsage = mempty } handleParseResult (overFailure f res)
When I enter a wrong argument the example program responds with the general usage pattern:
$ example --hello
Usage: args --hello TARGET [--quiet]
An error message like "missing parameter for option 'hello'" would be more helpful.
Or "option X required", "unknown option", "option parameter must be integer" etc.
The text was updated successfully, but these errors were encountered: