-
Notifications
You must be signed in to change notification settings - Fork 86
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
[Question] positional
argument with at least one value mandatory
#13
Comments
There is not currently, I'd potentially be open to a PR depending on how it's implemented. I'd suggest checking after parsing if it meets the conditions for now. |
Proposal#[derive(FromArgs)]
/// MyCMD
struct Opt {
#[argh(positional(1))] // expected number of items
/// script files to run
test_file: Vec<PathBuf>,
} if minimum number of expected item > 0, do not print brackets. I'm not very familiar with proc_macro yet, so I don't know if this is acceptable :) EDIT: I'm checking after parsing for now, yes :) EDIT2: even better? if not Option<_>, it is mandatory, regardless of the field kind |
I started hacking this type of syntax into the attribute macro, but it seems that the requested functionality is unclear. Should inside the parenthesis be the exact expected number of values or the minimum number number of values expected? I'm able to get the macro syntax to play nice, i.e |
Good question, my first post speaks about "at least" and the 2nd post is "expected number of items". Is it possible to specify something like: |
I didn't see that ability in my exploration. I only saw meta data capabilities for key value pairs which would allow Ben Brittain or another maintainer would know much better than me. |
Is there a way to specify that a positional arg need at least one value?
gives me:
Which suggests the tool can work without any input when it needs at least one.
The text was updated successfully, but these errors were encountered: