-
Notifications
You must be signed in to change notification settings - Fork 0
Usage parsing and generation should match docopt #230
Comments
Comment by pksunkara
|
Comment by epage
DocOpt is a convention for describing usage syntax, especially for creating arg parsers off of it.
As mentioned in the Issue, we at least differ in syntax for required (
I believe @kbknapp said that the goal of The other benefit is the closer we are to a common syntax, the more likely people will be able to translate existing knowledge when programming in Rust which makes them more successful faster and are less reliant on how perfect / complete our documentation is. If we decide docopt support isn't important, or if usage and parser can diverge, I'm fine with that. I'm more so just describing how I see the situation. Personally, I'll never use the docopt parser and the usage generation is good enough. |
Comment by kbknapp I could be wrong and misremembering, but I thought I remembered @BurntSushi mentioning once that there either wasn't a real spec, or it wasn't clear? One the main issues and why I never fully pursued this further was docopt I believe relies on "whole document" information to infer some settings for arguments and goes through great lengths to make good guesses. clap's "usage parsing" is much more strict, but also tried to encode things that docopt has no concept of. Ultimately, this was something I felt could be better handled by a crate wrapping clap, than clap itself. Like our derive and generating crates, I wouldn't mind them being part of this org, but a true docopt implementation is too much for clap proper. |
Comment by pksunkara So, there are two things here.
For the second item, I think we are all aligned that it can be a separate crate. I personally don't mind either but it might be difficult because we would want to implement Let's focus this issue on the first item. I personally think docopt is not the convention and
I asked the question for future so that we can actually do that when we work on this. |
Comment by kbknapp
Correct. For that exact method we'd have to create and expose some kind of |
Comment by 0x7FFFFFFFFFFFFFFF
What do you think of |
Comment by kbknapp
The only specification I've seen only says, (paraphrasing) "square brackets I've anecdotally seen |
Comment by epage
I only had in mind getting ours more inline with docopt. Are you suggesting we split our existing usage parser into its own crate or if someone wanted a to go full docopt? |
Comment by BurntSushi It's been a long time since I've even thought about docopt, but IIRC, docopt.org is pretty much the only thing that exists for a spec. I remember following that and the test cases for the reference implementation. IMO, this is a great piece of "fat" that could be trimmed from Clap. It's also worth noting that the docopt project itself (not just the docopt Rust library) has been effectively unmaintained for many years. |
Comment by epage
What are thoughts on deprecating the usage parser for 3.0, like we did the macro API?
|
Comment by pksunkara I have seen quite a high number of people use it. Every alternate issue that we get seems to use it. Maybe we can mark it as deprecated (without reverting changes) but offer it as a side crate later? |
Comment by epage Thanks for the input on its usage. If we do anything but plan to keep it as-is long term, we should revert the 3.0 API changes to reduce churn for those using it. |
Comment by pksunkara After 3.0, maybe we can do some metric collection and then decide on it? |
Comment by epage The only easy form of metric collection is |
Comment by pksunkara Agree, We can definitely explore in that direction after 3.0 |
Comment by epage If we are looking to radically change the API after 3.0, should we revert the API changes we did make?
|
Comment by epage As an alternative, what if we expose a subset of |
Issue by epage
Tuesday Oct 26, 2021 at 20:53 GMT
Originally opened as clap-rs/clap#2951
Affected Version of clap
3.0.0-beta.4
Expected Behavior Summary
App:from
parses according to http://docopt.org/App::render_usage
generates output that matches http://docopt.org/Actual Behavior Summary
At least with "required", we are using
<>
instead of()
See clap-rs/clap#2947
Notes
App::from
The text was updated successfully, but these errors were encountered: