summaryrefslogtreecommitdiff
path: root/src/cli.rs
blob: 506318757a2a3079104f667b8fe22fe91402278f (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use clap::{Parser, Subcommand};
use std::path::PathBuf;

#[derive(Parser)]
#[command(name = "squid-downloader")]
#[command(author = "Squid Downloader")]
#[command(version = "0.1.0")]
#[command(about = "Download high-quality music from multiple streaming services", long_about = None)]
#[command(color = clap::ColorChoice::Always)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,

    #[arg(
        short,
        long,
        global = true,
        help = "Output directory for downloads"
    )]
    pub output: Option<PathBuf>,

    #[arg(short, long, global = true, help = "Audio quality", value_parser = ["hires", "lossless", "high", "low", "mp3"])]
    pub quality: Option<String>,

    #[arg(short, long, global = true, help = "Streaming service", value_parser = ["tidal", "amazon", "soundcloud", "khinsider"])]
    pub service: Option<String>,

    #[arg(
        long,
        global = true,
        help = "Suppress non-essential output"
    )]
    pub quiet: bool,

    #[arg(
        short = 'j',
        long,
        global = true,
        help = "Max concurrent downloads (default: CPU cores)"
    )]
    pub concurrent: Option<usize>,

    #[arg(short = 'd', long, global = true, help = "Directory organization mode", value_parser = ["playlist", "album", "artist", "flat"])]
    pub dir_mode: Option<String>,
}

#[derive(Subcommand)]
pub enum Commands {
    #[command(about = "Search for tracks")]
    Search {
        #[arg(help = "Search query (song title)")]
        query: String,

        #[arg(
            short,
            long,
            help = "Artist name to improve accuracy"
        )]
        artist: Option<String>,

        #[arg(
            short = 'n',
            long,
            default_value = "10",
            help = "Number of results"
        )]
        limit: usize,
    },

    #[command(about = "Download a single track")]
    Track {
        #[arg(help = "Track ID or search query")]
        input: String,

        #[arg(
            short,
            long,
            help = "Artist name to improve accuracy"
        )]
        artist: Option<String>,

        #[arg(
            short = 'f',
            long,
            help = "Download first result without prompting"
        )]
        first: bool,
    },

    #[command(about = "Download an entire album")]
    Album {
        #[arg(help = "Album ID or search query")]
        input: String,
    },

    #[command(about = "Download tracks from an artist")]
    Artist {
        #[arg(help = "Artist ID or search query")]
        input: String,
    },

    #[command(about = "Download a playlist")]
    Playlist {
        #[arg(help = "Playlist ID or URL")]
        input: String,
    },

    #[command(about = "Import and download tracks from CSV file")]
    Csv {
        #[arg(help = "Path to CSV file")]
        file: PathBuf,

        #[arg(
            short = 't',
            long,
            default_value = "0.6",
            help = "Minimum confidence threshold (0.0-1.0)"
        )]
        threshold: f64,

        #[arg(
            short = 'y',
            long,
            help = "Skip confirmation prompt"
        )]
        yes: bool,
    },

    #[command(about = "Show information about a track")]
    Info {
        #[arg(help = "Track ID")]
        id: u64,
    },

    #[command(about = "Get recommendations for a track")]
    Recommend {
        #[arg(help = "Track ID")]
        id: u64,
    },

    #[command(about = "List available qualities and services")]
    List,
}

impl Cli {
    pub fn parse() -> Self {
        Parser::parse()
    }
}