-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Support for required parameter/argument #82
Comments
I'll expand on this a little. The current way you do this, is something like this: const option = args.args.option orelse fatal("Missing argument `--option`"); I think this is perfectly reasonable, but I do understand that if If we really want this it needs to be fleshed out. How would one then specify that the parameter is required using the recommended way of constructing parameters? This is the currently recommended way if you need nothing advanced: const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-n, --number <usize> An option parameter, which takes a value.
\\-s, --string <str>... An option parameter which can be specified multiple times.
\\<str>...
\\
); |
Great question @Hejsil. I see we need something solid here.
On the other hand maybe we could invert it?(breaking)
Side note: TBH I have no good answer for such change. Is there any variation you like? |
Geeh, don't really like any of them, but if we really wanted to pick one, then it should at least be the none breaking
Are you referring to something similar to what Also, I don't mind breaking changes if they are really an improvement over what was there before. Since Zig is not a stable language, I don't think it makes sense for libraries to care about stability yet either. |
Yes, that's what I was looking for! Thanks @Hejsil |
Hi, I would go with
And I would even go further with this:
I would like an OK, before I start working on it. It would be a breaking change, but [optional] and is the way everybody does this. |
@voroskoi Yep, that looks good to me 👍 |
Aah, ok that accept might have been a little hasty. Looking into what tends to be done here I've found out the following. Programs tends to define
Also, thinking more about it, I really don't want to break anything existing here. Most arguments will be optional, so breaking the |
Hi there,
Great job with this library so far!
I'm missing
required
parameter functionality. Would it make sense for you to add it ?I see that we could (in rough words) extend this function
with a field
.required: bool = false
and extend Errors with something like this:I think I can prepare PR with such change.
This is only proposition of changes. What do you think ?
The text was updated successfully, but these errors were encountered: