These are chat archives for kbknapp/clap-rs

9th
Apr 2015
Christoph Burgdorf
@cburgdorf
Apr 09 2015 06:40
Ah, makes perfect sense yes!
Christoph Burgdorf
@cburgdorf
Apr 09 2015 21:57
Can I configure clap to automatically print the help if my program is called without any arguments?
Kevin K.
@kbknapp
Apr 09 2015 22:10
Its funny that you mention that...I'm actually working on something close to that right now
Almost done
I'm adding a matches.usage() (so it's not the full help because that takes longer to generate and most of the time you don't want to print the entire thing since some programs have a ton of options, just a quick usage string). Then you can call something like std::process::exit(usize) to quit
Kevin K.
@kbknapp
Apr 09 2015 22:55
I just pushed the new version
0.5.13 on crates.io
if you determine the user hasn't used any args, you can call something like
println!("{}", matches.usage().unwrap()); 
println!("Re-run with --help for more information");
std::process::exit(1);
reason for the .unrap() is currently the matches.usage() is only for the top level app, i.e. not subcommands (which clog doesn't have right now, so it's kind of moot), for subcommands it returns None
Kevin K.
@kbknapp
Apr 09 2015 23:01
I considered having the .usage() do the exiting...but there are times where people may want to say more first, and THEN exit...so I'm leaving it up to them to decide when to exit