-
Notifications
You must be signed in to change notification settings - Fork 107
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
would like support for "cmd <source>... <destination>" #5
Comments
See also docopt/docopt#46 proposing to add this to the Python implementation, and apparently rejected. To me the implementation there is a straightforward way to write it: a repeated item can optionally be followed by a fixed number of non-repeating items. |
…cp-style repeated args docopt/docopt.go#5
docopt/docopt#46 was closed mostly because we were afraid of too much complexity in implementation and ambiguity in semantics. Right now the semantics is simple—matching is greedy. If you make matching non-greedy you need to define some semantics that would resolve cases like:
This starts to be a regular-expression-matching problem. But unlike in regular expressions, we don't have a way to control greediness as with If anyone can come up with nice simple solution to that, I would be more than happy to incorporate it in Python version of docopt. |
I respectfully disagree: you don't need to resolve those cases because
|
If you don't want to allow these cases, then you have another problem—now you need to distinguish them. Should it be a whitelist, you think?
|
One possible rule is the one I gave above, restated to be more unambiguous as:
Then these are OK and unambiguous:
but this is not:
I think the last of them is contrived and not useful, nor very obvious to humans how it's supposed to be interpreted. I guess this would be a command that can either take
ie you must take one a, then if possible one b, then the rest of them are a. Perhaps it is better spelled out as two alternatives, which is probably how I'd think of it:
|
There is definitely ambiguity for me in |
You could reasonably say that the optional arguments fill up from the left, But, anyhow: if this is too ambiguous, it doesn't have to be supported. The But there are lots of programs that have cp-like syntax, ie with one On Sun Feb 09 2014 at 04:23:02, Vladimir Keleshev [email protected]
|
I would love to write programs in that style as well. We just need to come up with a rule that is easy to convey to the user. Something like: A pattern with single |
Rather than take into account all cases with a general solution, maybe the best place to start is to just handle the most common case: a pattern with a single |
any news on this ? |
@mboersma any reasons you labeled this wontfix ? |
@smaftoul I think I marked this Having said that, that decision was years ago, and in the meantime we've seen docopt stagnate. I think the implementations work reasonably well as-is, but there has been little maintenance. It seems unlikely we could get any changes made to the core Python implementation, and I'd rather not have the go implementation diverge from that. But I'm just someone who volunteered to help maintain this library and if there's a PR with community support I would certainly review it. |
I have a cp-like command that takes multiple sources and a single destination. I'm trying to replicate that with docopt, but it consumes all of the input args for the
I tool a look at the source, for match(). I couldn't see any way to make this change. If you have any suggestions, I would be happy to work on a patch.
The text was updated successfully, but these errors were encountered: