summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-08-07 15:19:20 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-09-05 16:18:11 +0200
commit58fd2dbfe44f6213b3b9f13dd78063b1cbd0f78e (patch)
treeb93d4cbdba96561d35700fe39963c0574070ab92 /bin
parentfa379a2fa730c495e30d564a95d6a3223b00c5fc (diff)
Shrink App setup code
Diffstat (limited to 'bin')
-rw-r--r--bin/src/main.rs60
1 files changed, 27 insertions, 33 deletions
diff --git a/bin/src/main.rs b/bin/src/main.rs
index d40a022b..7a2f3d0e 100644
--- a/bin/src/main.rs
+++ b/bin/src/main.rs
@@ -102,40 +102,34 @@ fn get_commands() -> Vec<String> {
}
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 appname = "imag";
+ let version = &version!();
+ let about = "imag - the PIM suite for the commandline";
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")
- .long("version")
- .takes_value(false)
- .required(false)
- .multiple(false)
- .help("Get the version of imag"))
- .arg(Arg::with_name("versions")
- .long("versions")
- .takes_value(false)
- .required(false)
- .multiple(false)
- .help("Get the versions of the imag commands"))
- .arg(Arg::with_name("help")
- .long("help")
- .short("h")
- .takes_value(false)
- .required(false)
- .multiple(false)
- .help("Show help"));
-
-
- let matches = app.get_matches();
+ 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)
+ .multiple(false)
+ .help("Get the version of imag"))
+ .arg(Arg::with_name("versions")
+ .long("versions")
+ .takes_value(false)
+ .required(false)
+ .multiple(false)
+ .help("Get the versions of the imag commands"))
+ .arg(Arg::with_name("help")
+ .long("help")
+ .short("h")
+ .takes_value(false)
+ .required(false)
+ .multiple(false)
+ .help("Show help"))
+ .get_matches();
if matches.is_present("help") {
help(get_commands());