Use bpaf for argument parsing#527
Conversation
|
@davidlattimore I spent some time reading bpaf docs and tutorials. I think I understand how @pacak intended for it to be used. But that vision is different from what you described in #458, where you propose to manually consume arguments. Can you please explain how you want Another question: is it a valid combination to parameters to provide both Thanks. |
Yep, the initial
Yes, later arguments should override earlier ones. If unsure, you can try doing the same thing with GNU ld. e.g, the following command completes without error or warning: gcc -Wl,-gc-sections -Wl,-no-gc-sections main.c |
|
Do we have a corpus to use to make tests? |
I find corpus based testing tends to result in lots of redundant testing. So they're good for finding problems, at which point you write a proper, minimal test for that bug, but I wouldn't want to be running on a large test corpus with every PR for example. But I guess given that you're commenting on this PR, you're talking about specifically for argument parsing? There's some existing tests, although we could probably benefit from a few more. But I'd say the argument for hand-writing them would be even stronger there. |
Yes :)
Recently I got a request to minimize/normalize link lines in cargo-c so I was looking exactly at those corner cases to explain why collecting the arguments in a set may lead to wrong results. |
|
FYI: I proposed a different approach. The choice of which approach to use remains open for consideration. #1029 |
|
It is a bit reinventing the wheel, but given that this PR is on hold since a long time... |
|
We can still potentially switch to bpaf in future |
|
While it may initially appear that we're reinventing the wheel, there are several subtle requirements that existing argument parser frameworks like clap or bpaf cannot fulfill—primarily to maintain compatibility with existing linkers such as GNU ld. |
|
There are ways to meet those requirements with bpaf. See comments by pacak on #458. I guess the question then would be whether the code to do these with bpaf is more or less readable than the without bpaf. |
By all means. That'd be good to see what it'd look like with bpaf. We wouldn't want to use an external crate for argument parsing just for the sake of it though, so we'd only want to merge it if it gave us some benefit like better error messages or substantially simpler code. |
|
Given the age of the PR and the fact it conflicts with the |
Use bpaf crate for argument parsing. Currently this PR is for discussion purposes only.
Relates to #458