diff options
Diffstat (limited to 'src/cmd/recommend.rs')
-rw-r--r-- | src/cmd/recommend.rs | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/src/cmd/recommend.rs b/src/cmd/recommend.rs index 2f613fa..1d8eecc 100644 --- a/src/cmd/recommend.rs +++ b/src/cmd/recommend.rs @@ -19,40 +19,48 @@ pub fn subcommand<'a, 'b>() -> clap::App<'a, 'b> { .arg( clap::Arg::with_name("count") .default_value("20") - .help("number of results to return") + .help("number of results to return"), ) .arg( clap::Arg::with_name("random") .long("random") - .help("picks randomly instead of by weight") + .help("picks randomly instead of by weight"), ) .arg( clap::Arg::with_name("album") .long("album") - .help("also choose a random album by the chosen artists") + .help("also choose a random album by the chosen artists"), ) .arg( clap::Arg::with_name("include") .long("include") .default_value("yearly") - .possible_values(&["all", "yearly", "monthly", "weekly"]) + .possible_values(&["all", "yearly", "monthly", "weekly"]), ) .arg( clap::Arg::with_name("exclude") .long("exclude") .default_value("weekly") - .possible_values(&["all", "yearly", "monthly", "weekly", "none"]) + .possible_values(&[ + "all", "yearly", "monthly", "weekly", "none", + ]), ) } impl Command { - pub fn new<'a>(matches: &clap::ArgMatches<'a>) -> failure::Fallible<Command> { + pub fn new<'a>( + matches: &clap::ArgMatches<'a>, + ) -> failure::Fallible<Command> { Ok(Command { count: matches.value_of("count").unwrap().parse()?, random: matches.is_present("random"), album: matches.is_present("album"), - include: db::parse_timewindow(matches.value_of("include").unwrap()), - exclude: db::parse_timewindow(matches.value_of("exclude").unwrap()), + include: db::parse_timewindow( + matches.value_of("include").unwrap(), + ), + exclude: db::parse_timewindow( + matches.value_of("exclude").unwrap(), + ), db: db::DB::new(&util::db_path()?)?, }) @@ -65,21 +73,24 @@ impl super::Command for Command { self.count, self.random, self.include, - self.exclude + self.exclude, )?; if self.album { - artists = artists.iter().map(|artist| { - Ok(format!( - "{} - {}", - artist, - self.db.recommend_album( - &artist, - self.random, - self.include, - self.exclude - )? - )) - }).collect::<failure::Fallible<Vec<String>>>()?; + artists = artists + .iter() + .map(|artist| { + Ok(format!( + "{} - {}", + artist, + self.db.recommend_album( + &artist, + self.random, + self.include, + self.exclude + )? + )) + }) + .collect::<failure::Fallible<Vec<String>>>()?; } for line in artists { println!("{}", line); |