From 96c8e1e5ac561e450b78912f65b2415d41fc6a58 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 23 Dec 2018 02:49:04 -0500 Subject: rust 2018 --- src/cmd/mod.rs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/cmd/mod.rs (limited to 'src/cmd/mod.rs') diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs deleted file mode 100644 index e793b55..0000000 --- a/src/cmd/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -mod recommend; -mod sql; -mod sync; - -const _DUMMY_DEPENDENCY: &str = include_str!("../../Cargo.toml"); - -trait Command { - fn run(&self) -> failure::Fallible<()>; -} - -pub fn run() -> failure::Fallible<()> { - get_command()?.run() -} - -fn get_command() -> failure::Fallible> { - let subcommands = vec![ - sync::subcommand(), - sql::subcommand(), - recommend::subcommand(), - ]; - let mut app = app_from_crate!().subcommands( - subcommands - .into_iter() - .map(|s| s.setting(clap::AppSettings::DisableVersion)), - ); - let matches = app.clone().get_matches(); - - let command: Box = match matches.subcommand() { - ("sync", Some(matches)) => Box::new(sync::Command::new(matches)), - ("sql", Some(matches)) => Box::new(sql::Command::new(matches)), - ("recommend", Some(matches)) => { - Box::new(recommend::Command::new(matches)?) - } - - (name, Some(_)) => bail!("unknown subcommand: {}", name), - (_, None) => { - let mut stderr = std::io::stderr(); - app.write_long_help(&mut stderr)?; - eprintln!(""); - bail!("no subcommand given") - } - }; - - Ok(command) -} -- cgit v1.2.3-54-g00ecf