summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-11-07 20:48:13 -0500
committerJesse Luehrs <doy@tozt.net>2018-11-07 20:48:13 -0500
commit544b316bbaa36448b3272c4e00cd21c07fe0971d (patch)
treede3e491fd9e0f03026dd3a9cf66119c0ba8f014d /src/main.rs
parent4f0fe4efb761670fac366122d1f724f54b075b76 (diff)
downloadlastfm-query-544b316bbaa36448b3272c4e00cd21c07fe0971d.tar.gz
lastfm-query-544b316bbaa36448b3272c4e00cd21c07fe0971d.zip
move subcommands to their own file
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/main.rs b/src/main.rs
index 55e1725..dc307f6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,39 +12,16 @@ extern crate serde_json;
extern crate serde_derive;
mod cli;
+mod cmd;
mod exporter;
mod lastfm;
mod paths;
mod db;
-fn sync(opts: &cli::Options) -> failure::Fallible<()> {
- let db = db::DB::new(&paths::dbpath())?;
- let lastfm = lastfm::LastFMClient::new(
- opts.api_key.as_ref().unwrap(),
- opts.username.as_ref().unwrap()
- );
-
- let exporter = exporter::Exporter::new(&db, &lastfm);
-
- let to_fetch = exporter.tracks_to_sync()?;
- let bar = indicatif::ProgressBar::new(to_fetch);
- bar.set_style(
- indicatif::ProgressStyle::default_bar()
- .progress_chars("=> ")
- .template("Downloading {pos}/{len} tracks...\n{percent:>3}% [{wide_bar}] {eta:5}")
- );
-
- exporter.sync(|_| { bar.inc(1); })?;
-
- bar.finish_with_message("done");
-
- Ok(())
-}
-
fn run() -> failure::Fallible<()> {
let opts = cli::get_options()?;
match opts.command {
- cli::Command::Sync => sync(&opts),
+ cli::Command::Sync => cmd::sync::run(&opts),
}
}