summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-11-07 10:01:18 -0500
committerJesse Luehrs <doy@tozt.net>2018-11-07 10:01:18 -0500
commit1e1a47061c455a5324d8a62fa9bcee9ecdf9c4cb (patch)
tree905d0a1f8bdc8995e924a559f1dee313a612079a /src/main.rs
parent2f5bc1cb9f31d431d017d173728fd1e782c97c8e (diff)
downloadlastfm-query-1e1a47061c455a5324d8a62fa9bcee9ecdf9c4cb.tar.gz
lastfm-query-1e1a47061c455a5324d8a62fa9bcee9ecdf9c4cb.zip
better command line parsing
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 3434827..c4c255e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
+#[macro_use]
+extern crate clap;
extern crate directories;
extern crate failure;
extern crate indicatif;
@@ -8,6 +10,7 @@ extern crate serde_json;
#[macro_use]
extern crate serde_derive;
+mod cli;
mod error;
mod exporter;
mod lastfm;
@@ -15,16 +18,11 @@ mod paths;
mod db;
fn main() {
- let args: Vec<_> = std::env::args().collect();
- if args.len() < 3 {
- panic!("usage: {} USERNAME API_KEY", args[0]);
- }
- let username = &args[1];
- let api_key = &args[2];
+ let opts = cli::get_options();
let db = db::DB::new(&paths::dbpath())
.expect("failed to create db");
- let lastfm = lastfm::LastFMClient::new(api_key, username);
+ let lastfm = lastfm::LastFMClient::new(&opts.api_key, &opts.username);
let exporter = exporter::Exporter::new(&db, &lastfm);
let to_fetch = exporter.tracks_to_sync().unwrap();