-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Docopt library #4658
Comments
I feel like this should be a third party library and not in the std/core library. Considering that all of the implementations are installed using language-based package managers, that seems the norm. |
I agree with z0w0 that such a thing is beyond the scope of libcore (maybe not libstd). However, this sort of thing relies upon compile-time transformations, which requires a syntax extension, which currently must be defined in the compiler. If nothing else this is a plea for an API for externally-defined syntax extensions. |
nominating for far-future; it doesn't look like there would be any backward-compatibility issues or anything. |
just a bug, removing milestone/nomination. |
docopt looks awesome! since loadable syntax extensions are coming, this could probably work out really well. |
So I'm marking this E-easy and E-mentor, offering myself as the mentor. I'll post an update once #11151 lands. This isn't trivial, but it shouldn't be too hard, either. It involves parsing the input and generating the correct AST to implement the parsing / structures of the input. We could also add some lightweight typing to docopt. This is not suitable for a complete beginner. |
Loadable syntax have extended (#11151) |
I'm still kinda toying around with this, but sadly I don't have much time at the moment. |
Is there room for a more-convenient (but less elaborate) alternative to getopts in extra::? I'm often frustrated by how verbose code that uses getopts can get, and I think something similar to go's "flag" package (but based on getopts for consistency) would be nice. |
DocOpt is a fantastic third party library that I've used in Python to great advantage. However like everyone else I believe it should be just that. A third party library. imo it doesn't really belong in libcore. |
I would love to see this in Rust. Sure it shouldn't be in core but there are other libs included as part of rust, there is 'extern crate getopt' already and I don't really see that being more appropriate. The main issue is it would probably need a regex library if you follow the Python implementation, otherwise maybe a tokenizer implementation. |
I think a tokeniser based solution would be more 'rustic'. It would be a difficult port though. |
I am working on a docopt port to Rust since the current one seems dead. @bjz's instincts were right. This project was an order of magnitude more difficult than I thought it would be. The difficulty wasn't related to Rust in any way, but in interpreting the upstream spec (hint: there isn't one). My project has the hard parts done: parsing usage patterns, matching argv and storing the relevant values. Now I just need to clean up my code, write tests and come up with a nice public interface, probably by using a macro. Also, my port implements a proper backtracking search, so patterns like |
They seriously have no grammar specification? o_o |
@bjz They want one: docopt/docopt#20 There are a lot of weird corner cases that aren't specified though. Are flags allowed more than one synonym? If a flag is repeated in one usage pattern, does that mean its value should always be a count/list even in other patterns where it isn't repeated? Things like that. I had to look at how the reference implementation worked to infer such things. |
I have a conforming implementation: https://github.com/BurntSushi/docopt.rs |
@BurntSushi is awesome. |
👍 |
@cmr ❤️ |
This would make creating command line interfaces much easier: http://docopt.org/
The text was updated successfully, but these errors were encountered: