Closed pintoflager closed 1 year ago
In addition to describing the scenario, could you copy/paste the output?
Sure thing mate, this is what it says:
error: Found argument 'GroupName' which wasn't expected, or isn't valid in this context
I was expecting behaviour like I have with my main cli when I use key: Option<String>
.
With that I don't have to give default value for the argument.
This is using clap v3 where it defaults flags to not take a value. You need to explicitly ask it to do so. This was changed in clap v4, so when clap_serde is updated to that, what you have should work.
The derive does a lot of stuff automatically for you based on the intent of your argument.
Ah, got it. I'm a happy derive user on my main cli and never really did any testing without it. Live and learn. thanks
If argument is set as
required = false
it seems to have no impact on argument rendered as an 'option'?Only way I was able to add optional flags was to give them default_value and hide it from the --help with
hide_default_value = true
I was testing with this toml:
cmd: target/debug/test node create FirstArg --group GroupName
Above fails when --group is defined, works without the flag though. Starts working as expected with or without --group flag when
default_value = "something"
is uncommented.Not a big issue, I was just curious. Thank you for your work on this, seems to be the only way to extend clap commands runtime.