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
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "spotterm", version, about = "A CLI to control Spotify")]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand, Debug)]
pub enum Command {
/// Log in to Spotify (PKCE authentication)
Login,
/// Show the currently playing track (Now Playing)
Status,
/// Search tracks / albums / artists
Search {
/// Search keywords (multiple words, space-separated)
#[arg(required = true)]
query: Vec<String>,
},
/// Play (search and play with a query, or resume with no query)
Play { query: Vec<String> },
/// Pause
Pause,
/// Skip to the next track
Next,
/// Skip to the previous track
Prev,
/// Toggle play/pause
Toggle,
/// Set the volume (0-100)
Vol {
#[arg(value_parser = clap::value_parser!(u8).range(0..=100))]
level: u8,
},
/// List the available devices
Devices,
/// Select a device and move playback to it
Device {
#[command(subcommand)]
action: DeviceAction,
},
/// Playlist operations
Playlist {
#[command(subcommand)]
action: PlaylistAction,
},
/// Library (saved tracks / albums)
Lib,
/// Interactive TUI (Now Playing dashboard)
Tui,
}
#[derive(Subcommand, Debug)]
pub enum DeviceAction {
/// Move playback to the device with the given name
Use {
#[arg(required = true)]
name: Vec<String>,
},
}
#[derive(Subcommand, Debug)]
pub enum PlaylistAction {
/// List playlists
Ls,
/// Play a playlist by name
Play {
#[arg(required = true)]
name: Vec<String>,
},
}