Is it possible to take an argument as both positional and by flag? #1818
-
I have a clap CLI where it's possible to do the following:
But I'd like to also allow the following:
Without breaking the first usage. Is that possible? I think that perhaps I can do it by by defining two |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
What you wrote is correct. We don't have any other way to do it. |
Beta Was this translation helpful? Give feedback.
-
You can hide the deprecated flag from the help message. |
Beta Was this translation helpful? Give feedback.
-
You can define |
Beta Was this translation helpful? Give feedback.
-
Hi @casey ping www.google.com | tee |
Beta Was this translation helpful? Give feedback.
-
I have the same issue and similar requirements. I'm using the derive interface. What I want is rather common, I just want to be able to accept multiple filenames via I guess I could use two different arg declarations, but I need the file names to go into the same |
Beta Was this translation helpful? Give feedback.
You can define
input_pos
asrequired_unless(input_flag)
. This will give you exactly what you want.