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
Ignore ellipsis in argument definition? #111
Comments
We are in the process of formalising the parser (right now it's a bit ad hoc). So we need to decide which characters will be allowed for which elements. I can see how special characters could be used in interesting ways, but which exactly? The first draft grammar (discussed in #4) is even more restrictive (but it shouldn't need to be):
Do you have a specific proposal/idea on which characters should be allowed? |
Wow that is really restrictive. A formal grammar specification would be great but I'd certainly be an advocate for docopt being quite liberal where it can be, and only restrictive where it needs to be. It's hard to foresee all use cases, especially when sometimes (like above) it is desirable for some names to be more descriptive than just a simple stand-in label, e.g. So to your answer your question, I would only disallow characters that would interfere with the parser, or would make parsing overly cumbersome. I'd also have a similar opinion on option and command names. |
I see how The point I'm trying to make is that docopt shouldn't be liberal in what it accepts :-) Like, we shouldn't allow weird unicode characters, that look similar to ascii; we shouldn't allow characters that lead to confusion. |
Hmm I think I'm still of the view though that it is not the responsibility of docopt to enforce such things, the robustness principle comes to mind: "Be conservative in what you do, be liberal in what you accept from others". In docopt's case I think the danger is in being too prescriptive you unintentionally forbid a lot of use-cases. Another example, in physics it is common to write
than
My point is, it is impossible to know beforehand all valid use-cases and, given docopt's potential application acroos a wide number of domains I think it would be a shame if it became overly dogmatic. |
-1, keep it simple. I don't like the idea of having ellipsis and/or complex argument expressions. |
@fsaintjacques those are not expressions, it's just about which characters are allowed inside |
I would allow (almost) any printable characters (as
|
I'm not sure about quotes, Also I remember writing weird things like |
Their special meaning in shells doesn't matter. I can use these when writing regex for |
+1 for allowing as much as possible in the printable ascii range -- I have no opinion about non-ascii unicode. Regarding worrying about what the shell accepts, I wouldn't:
|
docopt already supports syntax like
--b=<x,y,z>
for specifying options taking multiple arguments, but I'd like to be able to clearly specify options which take a delimited list of undefined length i.e. I'd like to be able to specify this in the usage pattern:e.g.
--b=<x...>
or---b=<x,y,...>
or--b=<number1,number2,...>
.Right now I just print
in my usage message but I think it would be clearer if this could be presented to the user in the argument pattern directly.
I'm aware I could just use two dots
..
and all would work fine but I think it would be syntacticly cleaner and desirable to be able to consistently use...
to denote repetition.The text was updated successfully, but these errors were encountered: