extern crate cargo_drone;
#[macro_use]
extern crate clap;
extern crate failure;
use cargo_drone::commands::*;
use clap::{App, AppSettings, SubCommand};
use failure::Error;
use std::process;
fn main() {
if let Err(error) = run() {
eprintln!("{}", error);
process::exit(1);
}
}
fn run() -> Result<(), Error> {
let app = App::new(crate_name!())
.bin_name("cargo")
.setting(AppSettings::SubcommandRequired)
.subcommand(
SubCommand::with_name("drone")
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.setting(AppSettings::SubcommandRequired)
.subcommand(flash::command())
.subcommand(gdb::command())
.subcommand(inspect::command())
.subcommand(itmdump::command())
.subcommand(server::command())
.subcommand(test::command()),
);
if let ("drone", Some(matches)) = app.get_matches().subcommand() {
match matches.subcommand() {
("flash", Some(matches)) => flash::run(matches),
("gdb", Some(matches)) => gdb::run(matches),
("inspect", Some(matches)) => inspect::run(matches),
("itmdump", Some(matches)) => itmdump::run(matches),
("server", Some(matches)) => server::run(matches),
("test", Some(matches)) => test::run(matches),
_ => Ok(()),
}
} else {
Ok(())
}
}