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

Error message not helpfull #82

Open
janwilmans opened this issue Jul 30, 2017 · 5 comments
Open

Error message not helpfull #82

janwilmans opened this issue Jul 30, 2017 · 5 comments

Comments

@janwilmans
Copy link

phooey.exe -h
Docopt usage string could not be parsed
Mismatched '['

message has no linenr, nor any text/tokens of line offending line.
I will add the reproduction scenario as soon as I figure out what line it is, by binary search elimination.

@janwilmans
Copy link
Author

janwilmans commented Jul 30, 2017

found it; the -a line is the offending line, or at least, when it is removed, the error disappears.
In fact it is not matching with the [-a (value)] , that actually doesn't make much sense and should probably have been [-a value]

static const char USAGE[] =
R"(DebugviewConsole )" VERSION_STR
R"(
    Usage: 
        DebugviewConsole [-a (value)] [-i <pattern>, --include <pattern>]... [-e <pattern>, --exclude <pattern>]... 

    Options:
      -h --help             Show this screen
      -a value              auto-newline [default: true]  // offending line
      -i <pattern>, --include <pattern>     include filter, may be specified multiple times
      -e <pattern>, --exclude <pattern>     exclude filter, may be specified multiple times

)";

@jaredgrubb
Copy link
Member

Yes, the error messages are not helpful. This is a limitation that we inherit from the docopt sources. I'd like to see this fixed, but I think it's a more global problem that just the C++ implementation. I'm always open to suggestions on this.

@janwilmans
Copy link
Author

janwilmans commented Aug 10, 2017

Ok, so what is efficient, should I try to improve this in the python implementation of docopt and you can pull it in / convert that somehow?

I guess better error messages would require more script/detailed parsing or analysis of the parser output ?

@indianakernick
Copy link
Contributor

indianakernick commented Nov 29, 2019

It seems like almost all errors fall through to this point. Simply printing out all the arguments that the user passed isn't useful. That line might as well be throw DocoptArgumentError("Error");. Though, to be fair, the python implementation has the same problem so maybe I'm complaining in the wrong place!

It seems like fixing this would involve rewriting a lot of code (and breaking parity because of better error messages). I really like this library and I'm almost willing to do that myself but I don't think it would be worth the effort (plus I'm pretty lazy!).


This issue has lead me to doing these sort of checks on my end (which sort of defeats the purpose of docopt a little bit). For example, I use Usage: test [--a --b] as the help text passed to docopt and Usage: test [--a | --b] as help text shown to the user. Then if the user writes test --a --b, I can check if both options are present and print out --a must be mutually exclusive with --b. I've also used this technique to get around #55. I really wish I didn't have to do this.

@jaredgrubb
Copy link
Member

I would love to see better error messages but I think it would be a lot of work -- almost a full rewrite. I would be open to it, but I think it's a big effort. This repo was mostly a port of the Python one, which (as you note) suffers from the same problem.

If someone wants to start that, I would be willing to work with them to do it in a way that is going to be successful.

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

3 participants