These are chat archives for kbknapp/clap-rs

11th
Oct 2017
David Peter
@sharkdp
Oct 11 2017 17:52
Hi, thank you for this fantastic library. This might be a very specific use case, but is there any possibility to hide flags/options from the short -h help text but not from the long --help text?
Kevin K.
@kbknapp
Oct 11 2017 20:05
Interesting...maybe making two distinct args, and setting Arg::hidden(true) to the short one?
You could add both of these args to a group and just check ArgMatches::occurrences_of("group") to see if either one was used
Other than than that, I'm not sure if there is a way as I don't think that question has come up before.
David Peter
@sharkdp
Oct 11 2017 20:22
Hm. Not sure if I phrased that correctly.. I would like to add a new option (in short and long form) for a feature that is not used very often (say -f, --feature). I was wondering if that option (both variants of it) could be hidden from the autogenerated short -h help text but still be shown for the autogenerated long --help text.
(Thanks!)
Kevin K.
@kbknapp
Oct 11 2017 21:33
Ah ok, my mistake! Currently that's not possible, but it could probably be added pretty easily. Unfortunately I don't have a ton of time to work on it at the moment, but I could add it to the tracker or mentor someone who wants to work on it
A work around would be to do something like ripgrep used to do and build two different app structs depending on if -h or --help was called since building the app struct takes only nanoseconds
I'm not sure about the current ripgrep source since clap supports differentiating between -h and --help natively, but in the benches folder of the clap source under 05_ripgrep.rs you can see how it used to be done
David Peter
@sharkdp
Oct 11 2017 21:38
Ok, thank you very much! If you think that would be a useful feature, it would be great if we could add it to the issue tracker (let me know if I should do it).
Kevin K.
@kbknapp
Oct 11 2017 21:38
Yeah go ahead and add it to the issue tracker! Thatway I'm at least reminded of it ;)
David Peter
@sharkdp
Oct 11 2017 21:54
Done, thank you for your help! By the way, it's a real pleasure to work with clap. Great work!