rustfm_scraper/app/mod.rs
1pub mod fetch;
2pub mod stats;
3
4use clap::Clap;
5
6/// Provides commands to download your listening history from Last.fm and export it to several formats
7#[derive(Clap)]
8#[clap(version = "1.0", author = "Nathaniel Ledford <nate@nateledford.com>")]
9pub struct Opts {
10 #[clap(subcommand)]
11 pub subcmd: SubCommand,
12}
13
14#[derive(Clap)]
15pub enum SubCommand {
16 Fetch(Fetch),
17 Stats(Stats),
18}
19
20// TODO add config subcommand and allow a default file location to be set
21
22/// A subcommand for fetching your listening history from Last.fm
23#[derive(Clap)]
24pub struct Fetch {
25 /// A Last.fm username
26 #[clap(short)]
27 pub username: Option<String>,
28 /// The page number to fetch. Defaults to first page.
29 #[clap(short)]
30 pub page: Option<i32>,
31 /// The number of results to fetch per page. Defaults to 50. Maximum is 200.
32 #[clap(short)]
33 pub limit: Option<i32>,
34 /// Beginning timestamp of a range - only display scrobbles after this time, in UNIX timestamp format
35 #[clap(short)]
36 pub from: Option<i64>,
37 /// End timestamp of a range - only display scrobbles before this time, in UNIX timestamp format
38 #[clap(short)]
39 pub to: Option<i64>,
40 /// Create new file, rather than append tracks to an existing file
41 #[clap(short = 'n', takes_value = false)]
42 pub new_file: bool,
43 /// Fetches all new tracks from beginning of current day, rather than since last saved track
44 #[clap(long, takes_value = false)]
45 pub current_day: bool,
46 /// Specify which file format to use. Defaults to json
47 #[clap(long)]
48 pub file_format: Option<String>,
49}
50
51/// A subcommand for calculating stats from a saved file
52#[derive(Clap)]
53pub struct Stats {
54 /// A Last.fm username
55 #[clap(short)]
56 pub username: Option<String>,
57}