1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pub mod fetch;
pub mod stats;

use clap::Clap;

/// Provides commands to download your listening history from Last.fm and export it to several formats
#[derive(Clap)]
#[clap(version = "1.0", author = "Nathaniel Ledford <nate@nateledford.com>")]
pub struct Opts {
    #[clap(subcommand)]
    pub subcmd: SubCommand,
}

#[derive(Clap)]
pub enum SubCommand {
    Fetch(Fetch),
    Stats(Stats),
}

// TODO add config subcommand and allow a default file location to be set

/// A subcommand for fetching your listening history from Last.fm
#[derive(Clap)]
pub struct Fetch {
    /// A Last.fm username
    #[clap(short)]
    pub username: Option<String>,
    /// The page number to fetch. Defaults to first page.
    #[clap(short)]
    pub page: Option<i32>,
    /// The number of results to fetch per page. Defaults to 50. Maximum is 200.
    #[clap(short)]
    pub limit: Option<i32>,
    /// Beginning timestamp of a range - only display scrobbles after this time, in UNIX timestamp format
    #[clap(short)]
    pub from: Option<i64>,
    /// End timestamp of a range - only display scrobbles before this time, in UNIX timestamp format
    #[clap(short)]
    pub to: Option<i64>,
    /// Create new file, rather than append tracks to an existing file
    #[clap(short = 'n', takes_value = false)]
    pub new_file: bool,
    /// Fetches all new tracks from beginning of current day, rather than since last saved track
    #[clap(long, takes_value = false)]
    pub current_day: bool,
    /// Specify which file format to use. Defaults to json
    #[clap(long)]
    pub file_format: Option<String>,
}

/// A subcommand for calculating stats from a saved file
#[derive(Clap)]
pub struct Stats {
    /// A Last.fm username
    #[clap(short)]
    pub username: Option<String>,
}