summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-11-10 01:32:42 -0500
committerJesse Luehrs <doy@tozt.net>2018-11-10 01:32:42 -0500
commit1c8a540c365f281b9f8dee171360347f0dc897ff (patch)
treee4dffad023db349ab72b99b21f3c19a6d985f229
parent26584b1cffa33eab6660c1673b6d87239402ab9e (diff)
downloadlastfm-query-1c8a540c365f281b9f8dee171360347f0dc897ff.tar.gz
lastfm-query-1c8a540c365f281b9f8dee171360347f0dc897ff.zip
move the run function into cli
-rw-r--r--src/cli.rs14
-rw-r--r--src/main.rs10
2 files changed, 13 insertions, 11 deletions
diff --git a/src/cli.rs b/src/cli.rs
index c2cae24..4b6aa0d 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,6 +1,8 @@
+use cmd;
+
const _DUMMY_DEPENDENCY: &'static str = include_str!("../Cargo.toml");
-pub enum Command {
+enum Command {
Sync {
username: String,
},
@@ -10,7 +12,15 @@ pub enum Command {
},
}
-pub fn get_options() -> failure::Fallible<Command> {
+pub fn run() -> failure::Fallible<()> {
+ let command = get_options()?;
+ match command {
+ Command::Sync { username } => cmd::sync::run(&username),
+ Command::SQL { query, tsv } => cmd::sql::run(&query, tsv),
+ }
+}
+
+fn get_options() -> failure::Fallible<Command> {
let matches = app_from_crate!()
.subcommand(
clap::SubCommand::with_name("sync")
diff --git a/src/main.rs b/src/main.rs
index b43f310..a4ce773 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,14 +18,6 @@ mod lastfm;
mod paths;
mod db;
-fn run() -> failure::Fallible<()> {
- let command = cli::get_options()?;
- match command {
- cli::Command::Sync { username } => cmd::sync::run(&username),
- cli::Command::SQL { query, tsv } => cmd::sql::run(&query, tsv),
- }
-}
-
fn program_name() -> failure::Fallible<String> {
let program = std::env::args()
.next()
@@ -39,7 +31,7 @@ fn program_name() -> failure::Fallible<String> {
}
fn main() {
- match run() {
+ match cli::run() {
Ok(_) => {},
Err(e) => {
let name = program_name()