Is there a way to require_equals
but also allow a default if there is no =
?
#5219
Unanswered
rageshkrishna
asked this question in
Q&A
Replies: 1 comment
-
After a little trial and error, I got the following to work: #[arg(
long,
default_missing_value = Some(""),
num_args = 0..=1,
default_value = None,
require_equals = true,
)]
pub foo: Option<String>, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to implement an argument that needs to allow the following usage:
How do I express this requirement in clap?
Of course the following doesn't work because
require_equals
will throw an error if it doesn't get an=
:This will output
error: equal sign is needed when assigning value
, as documented.Is there a way to require
=
for assignment, but assign default if no value was supplied?Beta Was this translation helpful? Give feedback.
All reactions