diff options
author | mario <mario-krehl@gmx.de> | 2016-09-03 17:58:14 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-09-05 16:18:11 +0200 |
commit | d19243e7a8942646e1b3529c61c246862fe31daa (patch) | |
tree | 2cd8de7225dab087925fdbdbe1d20a1604c66a7a /bin | |
parent | 882b2ef5a75307f9988e2cb9646449bf5ea8f311 (diff) |
Fall back to get_default_cli_builder
insert custom help text
cleanup not anymore used code
Diffstat (limited to 'bin')
-rw-r--r-- | bin/Cargo.toml | 3 | ||||
-rw-r--r-- | bin/src/main.rs | 32 |
2 files changed, 22 insertions, 13 deletions
diff --git a/bin/Cargo.toml b/bin/Cargo.toml index e07df830..4befe8dc 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -13,3 +13,6 @@ log = "0.3" [dependencies.libimagrt] path = "../libimagrt" +[dependencies.libimagerror] +path = "../libimagerror" + diff --git a/bin/src/main.rs b/bin/src/main.rs index 7076a2ea..25d47ce3 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -5,6 +5,7 @@ extern crate clap; extern crate walkdir; extern crate libimagrt; +extern crate libimagerror; use std::env; use std::process::exit; @@ -14,10 +15,10 @@ use std::io::ErrorKind; use walkdir::WalkDir; use crossbeam::*; -use clap::{Arg, App, AppSettings, SubCommand}; +use clap::{Arg, AppSettings, SubCommand}; use libimagrt::runtime::Runtime; -use libimagrt::setup::generate_runtime_setup; +use libimagerror::trace::trace_error; fn help_text(cmds: Vec<String>) -> String { let text = format!(r#" @@ -105,8 +106,14 @@ fn get_commands() -> Vec<String> { execs } -pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { - app + +fn main() { + let appname = "imag"; + let version = &version!(); + let about = "imag - the PIM suite for the commandline"; + let commands = get_commands(); + let helptext = help_text(commands); + let app = Runtime::get_default_cli_builder(appname, version, about) .settings(&[AppSettings::AllowExternalSubcommands]) .arg(Arg::with_name("version") .long("version") @@ -121,15 +128,14 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .multiple(false) .help("Get the versions of the imag commands")) .subcommand(SubCommand::with_name("help").help("Show help")) - .help(help_text(get_commands())) -} - -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(); + .help(helptext.as_str()); + let rt = Runtime::new(app) + .unwrap_or_else(|e| { + println!("Runtime couldn't be setup. Exiting"); + trace_error(&e); + exit(1); + }); + let matches = rt.cli(); debug!("matches: {:?}", matches); |