Fall back to get_default_cli_builder
insert custom help text cleanup not anymore used code
This commit is contained in:
parent
882b2ef5a7
commit
d19243e7a8
2 changed files with 22 additions and 13 deletions
|
@ -13,3 +13,6 @@ log = "0.3"
|
||||||
[dependencies.libimagrt]
|
[dependencies.libimagrt]
|
||||||
path = "../libimagrt"
|
path = "../libimagrt"
|
||||||
|
|
||||||
|
[dependencies.libimagerror]
|
||||||
|
path = "../libimagerror"
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ extern crate clap;
|
||||||
extern crate walkdir;
|
extern crate walkdir;
|
||||||
|
|
||||||
extern crate libimagrt;
|
extern crate libimagrt;
|
||||||
|
extern crate libimagerror;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
@ -14,10 +15,10 @@ use std::io::ErrorKind;
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use crossbeam::*;
|
use crossbeam::*;
|
||||||
use clap::{Arg, App, AppSettings, SubCommand};
|
use clap::{Arg, AppSettings, SubCommand};
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagerror::trace::trace_error;
|
||||||
|
|
||||||
fn help_text(cmds: Vec<String>) -> String {
|
fn help_text(cmds: Vec<String>) -> String {
|
||||||
let text = format!(r#"
|
let text = format!(r#"
|
||||||
|
@ -105,8 +106,14 @@ fn get_commands() -> Vec<String> {
|
||||||
execs
|
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])
|
.settings(&[AppSettings::AllowExternalSubcommands])
|
||||||
.arg(Arg::with_name("version")
|
.arg(Arg::with_name("version")
|
||||||
.long("version")
|
.long("version")
|
||||||
|
@ -121,15 +128,14 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.multiple(false)
|
.multiple(false)
|
||||||
.help("Get the versions of the imag commands"))
|
.help("Get the versions of the imag commands"))
|
||||||
.subcommand(SubCommand::with_name("help").help("Show help"))
|
.subcommand(SubCommand::with_name("help").help("Show help"))
|
||||||
.help(help_text(get_commands()))
|
.help(helptext.as_str());
|
||||||
}
|
let rt = Runtime::new(app)
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
fn main() {
|
println!("Runtime couldn't be setup. Exiting");
|
||||||
let appname = "imag";
|
trace_error(&e);
|
||||||
let version = &version!();
|
exit(1);
|
||||||
let about = "imag - the PIM suite for the commandline";
|
});
|
||||||
let rt = generate_runtime_setup(appname, version, about, build_ui);
|
let matches = rt.cli();
|
||||||
let matches = rt.cli();
|
|
||||||
|
|
||||||
debug!("matches: {:?}", matches);
|
debug!("matches: {:?}", matches);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue