-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add validator_all
, validator_all_os
#3029
Conversation
I'm a bit unsure what I think. Some random thoughts
While some of those comments are about plans that are probably months out, there is the workaround of handwriting this validator, rather than having clap do it. We've recently exposed To be clear, this is not a "no" but me sharing my thoughts as part of a conversation with you, other clap users, and other clap maintainers. ps Personally, I recommend issues or discussions for proposing new APIs since PRs couple any conversation we have to their PR when PRs might get created and discarded, depending on how the conversation goes. I wonder if we should encourage that in the CONTRIBUTING.md... |
@epage Thanks for your thoughts; I did not think that this would be without controversy, especially given #2832 where you want to go an entirely different direction than validators. I renamed MFEK/clap to MFEK/clap.rlib (i.e. made it match my org's house style) because I had a feeling I'd be maintaining a If you choose to decline this patch as better solved in the future by your changes, either the planned ones in #2832, or some other plan, that's fine. I'll use it for the meanwhile. |
What are your thoughts on the It'd look something like let mut app = ...;
let matches = app.get_matches_mut();
let arg_len = matches.values_of("arg").unwrap().len();
if arg_len % 2 != 0 {
app.error("--arg's values should be in pairs of two").exit();
} |
I like the fact that I know all validation is done when I have |
Personal opinion here; I would move this to post v3 if at all. We should definitely be in a feature freeze until v3 is released. Once it's released, I do expect there to be some discussion on where the line is between what is acceptable to punt to application code, vs what should be handled at the CLI level. The original intent of |
Do we at least all agree that it's a good general principle of software design to separate concerns, and that the concern of CLI argument parsing belongs to How we make |
Absolutely! I'm not saying we won't include this or something very similar, just that our resources are limited so we have to draw seemingly arbitrary lines between what clap handles and what gets pushed into application code. In this particular case there is a good workaround with minimal user code that can be used while we prioritize the v3 release and then re-evaluate. This particular issue also only tangentially touches a muddy part of the API that I'd love to take a more concerted look at (multiples values and everything they encompass) but that won't happen until v3 is released and that weight is lifted 😉 |
Since it seems we won't be moving forward with this design, I'm going ahead and closing this PR out. |
Hello friends, Congrats on the releases of 3.0 & 3.0.1! In commits f48280c and the less important ec5a075, MFEK's clap fork w/ I'd like to know if we can discuss this again now that 3.0 is out. I don't want to maintain this fork forever, though of course will if necessary, it's not a huge burden, am just hoping we can find consensus :) |
Without further input, this is feeling a bit specialized. I would lean towards recommending Maybe create an issue for this and we can see how much interest this garners. |
For MFEKstroke's new dash mode, I needed to be able to write a validator that would check and make sure that the number of values I had for an argument was divisible by two. Unable to do this with e.g.
min_values
etc. I decided to add new functionsvalidator_all
and an_os
counterpart as that is "theclap
way". Although I could've solved it just for me withvalidator_num
, I believe this is better because it puts the whole issue to bed.Also added tests for the new functions.