diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/mod.rs | 45 | ||||
-rw-r--r-- | src/cmd/recommend.rs | 4 | ||||
-rw-r--r-- | src/cmd/sql.rs | 4 | ||||
-rw-r--r-- | src/cmd/sync.rs | 6 |
4 files changed, 7 insertions, 52 deletions
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<Box<Command>> { - 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<Command> = 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) -} diff --git a/src/cmd/recommend.rs b/src/cmd/recommend.rs index 1d8eecc..413dc5f 100644 --- a/src/cmd/recommend.rs +++ b/src/cmd/recommend.rs @@ -1,5 +1,5 @@ -use db; -use util; +use crate::db; +use crate::util; use clap; diff --git a/src/cmd/sql.rs b/src/cmd/sql.rs index bf4b768..5abc5ef 100644 --- a/src/cmd/sql.rs +++ b/src/cmd/sql.rs @@ -1,5 +1,5 @@ -use db; -use util; +use crate::db; +use crate::util; use clap; diff --git a/src/cmd/sync.rs b/src/cmd/sync.rs index 2d5b25b..88fe95c 100644 --- a/src/cmd/sync.rs +++ b/src/cmd/sync.rs @@ -1,6 +1,6 @@ -use db; -use lastfm; -use util; +use crate::db; +use crate::lastfm; +use crate::util; use clap; |