These are chat archives for kbknapp/clap-rs

31st
Jul 2018
Ralf Jung
@RalfJung
Jul 31 2018 08:37
Is there a way, in clap/structopt, to add an "EXAMPLES" section to the output of "--help" that one show one or several examples of how to call the application?
I often find those tremendously useful
Kevin K.
@kbknapp
Jul 31 2018 14:25
You can use App::{before,after}_help
@RalfJung sorry, forgot to at-mention you :P
Ralf Jung
@RalfJung
Jul 31 2018 15:00
@kbknapp ah, thanks! now I guess I just have to see if I can access that from structopt.
Kevin K.
@kbknapp
Jul 31 2018 15:04
you can ;) #[structopt(after_help = "Foo bar baz")]
Ralf Jung
@RalfJung
Jul 31 2018 15:08

hm

error[E0599]: no method named after_help found for type structopt::clap::Arg<'_, '_> in the current scope

maybe something is too old
Kevin K.
@kbknapp
Jul 31 2018 15:10
Ah you have to add that to the struct definition, not the fields
``#[structopt(after_help = "Foo bar baz")] struct Foo;
Sorry I'm on mobile, my formatting is terrible
Ralf Jung
@RalfJung
Jul 31 2018 15:11
ah that does it :D
there was no such attribute yet
so I copy-pasted wrong
and even newlines work. awesome :)
Kevin K.
@kbknapp
Jul 31 2018 15:13
Glad it worked! :)
By the way, I've loved all your blogs I've seen posted to the subreddit! Keep them coming please!
Ralf Jung
@RalfJung
Jul 31 2018 15:16
<3