Shrink App setup code

This commit is contained in:
Matthias Beyer 2016-08-07 15:19:20 +02:00
parent fa379a2fa7
commit 58fd2dbfe4

View file

@ -105,16 +105,12 @@ fn main() {
let appname = "imag";
let version = &version!();
let about = "imag - the PIM suite for the commandline";
let mut app = Runtime::get_default_cli_builder(appname, version, about);
let commands = get_commands();
for command in commands.iter() {
let s = SubCommand::with_name(&command[..]);
app = app.subcommand(s)
}
let app = app.arg(Arg::with_name("version")
let r = Runtime::get_default_cli_builder(appname, version, about);
let matches = commands
.iter()
.fold(r, |app, cmd| app.subcommand(SubCommand::with_name(cmd)))
.arg(Arg::with_name("version")
.long("version")
.takes_value(false)
.required(false)
@ -132,10 +128,8 @@ fn main() {
.takes_value(false)
.required(false)
.multiple(false)
.help("Show help"));
let matches = app.get_matches();
.help("Show help"))
.get_matches();
if matches.is_present("help") {
help(get_commands());