summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs28
-rw-r--r--src/cmd/mod.rs27
-rw-r--r--src/cmd/sql.rs3
-rw-r--r--src/cmd/sync.rs3
-rw-r--r--src/main.rs3
5 files changed, 30 insertions, 34 deletions
diff --git a/src/cli.rs b/src/cli.rs
deleted file mode 100644
index b5ac878..0000000
--- a/src/cli.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use cmd;
-
-const _DUMMY_DEPENDENCY: &'static str = include_str!("../Cargo.toml");
-
-pub trait Command {
- fn run(&self) -> failure::Fallible<()>;
-}
-
-pub fn run() -> failure::Fallible<()> {
- get_command()?.run()
-}
-
-fn get_command() -> failure::Fallible<Box<Command>> {
- let matches = app_from_crate!()
- .subcommand(cmd::sync::subcommand())
- .subcommand(cmd::sql::subcommand())
- .get_matches();
-
- let command: Box<Command> = match matches.subcommand() {
- ("sync", Some(matches)) => Box::new(cmd::sync::Command::new(matches)),
- ("sql", Some(matches)) => Box::new(cmd::sql::Command::new(matches)),
-
- (name, Some(_)) => bail!("unknown subcommand: {}", name),
- (_, None) => bail!("no subcommand given"),
- };
-
- Ok(command)
-}
diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs
index a25e955..89c9f5b 100644
--- a/src/cmd/mod.rs
+++ b/src/cmd/mod.rs
@@ -1,2 +1,29 @@
pub mod sql;
pub mod sync;
+
+const _DUMMY_DEPENDENCY: &'static str = include_str!("../../Cargo.toml");
+
+pub trait Command {
+ fn run(&self) -> failure::Fallible<()>;
+}
+
+pub fn run() -> failure::Fallible<()> {
+ get_command()?.run()
+}
+
+fn get_command() -> failure::Fallible<Box<Command>> {
+ let matches = app_from_crate!()
+ .subcommand(sync::subcommand())
+ .subcommand(sql::subcommand())
+ .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)),
+
+ (name, Some(_)) => bail!("unknown subcommand: {}", name),
+ (_, None) => bail!("no subcommand given"),
+ };
+
+ Ok(command)
+}
diff --git a/src/cmd/sql.rs b/src/cmd/sql.rs
index f0dd4b0..d31f326 100644
--- a/src/cmd/sql.rs
+++ b/src/cmd/sql.rs
@@ -1,4 +1,3 @@
-use cli;
use db;
use paths;
@@ -33,7 +32,7 @@ impl Command {
}
}
-impl cli::Command for Command {
+impl super::Command for Command {
fn run(&self) -> failure::Fallible<()> {
let db = db::DB::new(&paths::db_path()?)?;
diff --git a/src/cmd/sync.rs b/src/cmd/sync.rs
index 3dc7ba8..5b71954 100644
--- a/src/cmd/sync.rs
+++ b/src/cmd/sync.rs
@@ -1,4 +1,3 @@
-use cli;
use db;
use lastfm;
use paths;
@@ -27,7 +26,7 @@ impl Command {
}
}
-impl cli::Command for Command {
+impl super::Command for Command {
fn run(&self) -> failure::Fallible<()> {
let db = db::DB::new(&paths::db_path()?)?;
let lastfm = lastfm::LastFMClient::new(&self.username)?;
diff --git a/src/main.rs b/src/main.rs
index a4ce773..d7adc8f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,7 +12,6 @@ extern crate serde_json;
#[macro_use]
extern crate serde_derive;
-mod cli;
mod cmd;
mod lastfm;
mod paths;
@@ -31,7 +30,7 @@ fn program_name() -> failure::Fallible<String> {
}
fn main() {
- match cli::run() {
+ match cmd::run() {
Ok(_) => {},
Err(e) => {
let name = program_name()