Shrink App setup code
This commit is contained in:
parent
fa379a2fa7
commit
58fd2dbfe4
1 changed files with 27 additions and 33 deletions
|
@ -102,40 +102,34 @@ fn get_commands() -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let appname = "imag";
|
let appname = "imag";
|
||||||
let version = &version!();
|
let version = &version!();
|
||||||
let about = "imag - the PIM suite for the commandline";
|
let about = "imag - the PIM suite for the commandline";
|
||||||
let mut app = Runtime::get_default_cli_builder(appname, version, about);
|
|
||||||
|
|
||||||
let commands = get_commands();
|
let commands = get_commands();
|
||||||
|
let r = Runtime::get_default_cli_builder(appname, version, about);
|
||||||
for command in commands.iter() {
|
let matches = commands
|
||||||
let s = SubCommand::with_name(&command[..]);
|
.iter()
|
||||||
app = app.subcommand(s)
|
.fold(r, |app, cmd| app.subcommand(SubCommand::with_name(cmd)))
|
||||||
}
|
.arg(Arg::with_name("version")
|
||||||
|
.long("version")
|
||||||
let app = app.arg(Arg::with_name("version")
|
.takes_value(false)
|
||||||
.long("version")
|
.required(false)
|
||||||
.takes_value(false)
|
.multiple(false)
|
||||||
.required(false)
|
.help("Get the version of imag"))
|
||||||
.multiple(false)
|
.arg(Arg::with_name("versions")
|
||||||
.help("Get the version of imag"))
|
.long("versions")
|
||||||
.arg(Arg::with_name("versions")
|
.takes_value(false)
|
||||||
.long("versions")
|
.required(false)
|
||||||
.takes_value(false)
|
.multiple(false)
|
||||||
.required(false)
|
.help("Get the versions of the imag commands"))
|
||||||
.multiple(false)
|
.arg(Arg::with_name("help")
|
||||||
.help("Get the versions of the imag commands"))
|
.long("help")
|
||||||
.arg(Arg::with_name("help")
|
.short("h")
|
||||||
.long("help")
|
.takes_value(false)
|
||||||
.short("h")
|
.required(false)
|
||||||
.takes_value(false)
|
.multiple(false)
|
||||||
.required(false)
|
.help("Show help"))
|
||||||
.multiple(false)
|
.get_matches();
|
||||||
.help("Show help"));
|
|
||||||
|
|
||||||
|
|
||||||
let matches = app.get_matches();
|
|
||||||
|
|
||||||
if matches.is_present("help") {
|
if matches.is_present("help") {
|
||||||
help(get_commands());
|
help(get_commands());
|
||||||
|
|
Loading…
Reference in a new issue