You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enhancementWe would love to have this feature! Feel free to supply a PRneed-designThe concrete desing is uncertain, please get involved in the discussion before sending a PR
In the same vein as convenience features like #134 and #18, add support for the automatic use of Default, if implemented. This would be a breaking change if done poorly, and in any case I'm not sure if the procedural macro system is powerful enough to "detect" trait implementations. I'd therefore propose the following syntax, inspired by #18:
#[derive(Debug)]structValue(String);implDefaultforValue{fndefault() -> Value{Value("default".to_string())}}implFromStrforValue{ ... }#[derive(Debug,StructOpt)]structOpt{// using the proposed automatic name syntax#[structopt(long, short,default)]value:Value}
Basically, if the default key is present, then use the Default trait if the flag isn't given. I'd also be okay with default_value being the key, but my suggestion is that it be slightly different because under the hood, something slightly different is happening. This isn't using clap's default_value builder method, since it requires a str. Rather, structopt itself will handle the logic for filling in the default value if necessary.
I'm not super familiar with this part of clap's design, but I figured we'd just instantiate a default value and print that. If there's a way to detect when clap is printing usage text, we can do it manually by appending the default value message to the usage for that field.
enhancementWe would love to have this feature! Feel free to supply a PRneed-designThe concrete desing is uncertain, please get involved in the discussion before sending a PR
Activity
TeXitoi commentedon Oct 12, 2018
Seems interesting and cleanly designed.
TeXitoi commentedon Oct 12, 2018
This is similar to #105
Lucretiel commentedon Oct 12, 2018
Can you assign this to me, so that it shows up in my dashboard?
TeXitoi commentedon Oct 12, 2018
Done
TeXitoi commentedon Oct 15, 2018
So what we do for the fact that clap want to print the default value?
Lucretiel commentedon Nov 2, 2018
I'm not super familiar with this part of clap's design, but I figured we'd just instantiate a default value and print that. If there's a way to detect when clap is printing usage text, we can do it manually by appending the default value message to the usage for that field.