Use libimagrt::setup::generate_runtime_setup() helper to build Runtime object
This commit is contained in:
parent
c4c726a983
commit
ac7fb19040
1 changed files with 18 additions and 11 deletions
|
@ -14,9 +14,10 @@ use std::io::ErrorKind;
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use crossbeam::*;
|
use crossbeam::*;
|
||||||
use clap::{Arg, AppSettings, SubCommand};
|
use clap::{Arg, App, AppSettings, SubCommand};
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
|
|
||||||
fn help(cmds: Vec<String>) {
|
fn help(cmds: Vec<String>) {
|
||||||
println!(r#"
|
println!(r#"
|
||||||
|
@ -102,15 +103,10 @@ fn get_commands() -> Vec<String> {
|
||||||
execs
|
execs
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
let appname = "imag";
|
get_commands()
|
||||||
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
|
|
||||||
.iter()
|
.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")
|
.arg(Arg::with_name("version")
|
||||||
.long("version")
|
.long("version")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
|
@ -132,21 +128,32 @@ fn main() {
|
||||||
.help("Show help"))
|
.help("Show help"))
|
||||||
.subcommand(SubCommand::with_name("help").help("Show help"))
|
.subcommand(SubCommand::with_name("help").help("Show help"))
|
||||||
.settings(&[AppSettings::AllowExternalSubcommands])
|
.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") {
|
if matches.is_present("help") {
|
||||||
|
debug!("Calling help()");
|
||||||
help(get_commands());
|
help(get_commands());
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("version") {
|
if matches.is_present("version") {
|
||||||
|
debug!("Showing version");
|
||||||
println!("imag {}", &version!()[..]);
|
println!("imag {}", &version!()[..]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("versions") {
|
if matches.is_present("versions") {
|
||||||
|
debug!("Showing versions");
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
for command in commands.iter() {
|
for command in get_commands().iter() {
|
||||||
result.push(crossbeam::scope(|scope| {
|
result.push(crossbeam::scope(|scope| {
|
||||||
scope.spawn(|| {
|
scope.spawn(|| {
|
||||||
let v = Command::new(command).arg("--version").output();
|
let v = Command::new(command).arg("--version").output();
|
||||||
|
|
Loading…
Reference in a new issue