summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-09-01 11:24:53 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-09-05 16:18:11 +0200
commitac7fb1904053eca82bcc55c44bb0e6d7907dda36 (patch)
treee41a5d58dfd88706c2870b678b2f3d75d2916ffe /bin
parentc4c726a9834790257c6a6d51cfc92ead66e1bcea (diff)
Use libimagrt::setup::generate_runtime_setup() helper to build Runtime object
Diffstat (limited to 'bin')
-rw-r--r--bin/src/main.rs29
1 files changed, 18 insertions, 11 deletions
diff --git a/bin/src/main.rs b/bin/src/main.rs
index 9ac30fb5..19c8c319 100644
--- a/bin/src/main.rs
+++ b/bin/src/main.rs
@@ -14,9 +14,10 @@ use std::io::ErrorKind;
use walkdir::WalkDir;
use crossbeam::*;
-use clap::{Arg, AppSettings, SubCommand};
+use clap::{Arg, App, AppSettings, SubCommand};
use libimagrt::runtime::Runtime;
+use libimagrt::setup::generate_runtime_setup;
fn help(cmds: Vec<String>) {
println!(r#"
@@ -102,15 +103,10 @@ fn get_commands() -> Vec<String> {
execs
}
-fn main() {
- let appname = "imag";
- let version = &version!();
- let about = "imag - the PIM suite for the commandline";
- let commands = get_commands();
- let r = Runtime::get_default_cli_builder(appname, version, about);
- let matches = commands
+pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
+ get_commands()
.iter()
- .fold(r, |app, cmd| app.subcommand(SubCommand::with_name(cmd)))
+ .fold(app, |app, cmd| app.subcommand(SubCommand::with_name(cmd)))
.arg(Arg::with_name("version")
.long("version")
.takes_value(false)
@@ -132,21 +128,32 @@ fn main() {
.help("Show help"))
.subcommand(SubCommand::with_name("help").help("Show help"))
.settings(&[AppSettings::AllowExternalSubcommands])
- .get_matches();
+}
+
+fn main() {
+ let appname = "imag";
+ let version = &version!();
+ let about = "imag - the PIM suite for the commandline";
+ let rt = generate_runtime_setup(appname, version, about, build_ui);
+ let matches = rt.cli();
+ debug!("matches: {:?}", matches);
if matches.is_present("help") {
+ debug!("Calling help()");
help(get_commands());
exit(0);
}
if matches.is_present("version") {
+ debug!("Showing version");
println!("imag {}", &version!()[..]);
exit(0);
}
if matches.is_present("versions") {
+ debug!("Showing versions");
let mut result = vec![];
- for command in commands.iter() {
+ for command in get_commands().iter() {
result.push(crossbeam::scope(|scope| {
scope.spawn(|| {
let v = Command::new(command).arg("--version").output();