spotify_cli/cli/args/
player.rs

1//! Player-related command definitions.
2
3use clap::Subcommand;
4
5#[derive(Subcommand)]
6pub enum PlayerCommand {
7    /// Skip to next track (alias: n)
8    #[command(alias = "n")]
9    Next,
10    /// Skip to previous track (alias: prev)
11    #[command(alias = "prev")]
12    Previous,
13    /// Toggle playback (play/pause) (alias: t)
14    #[command(alias = "t")]
15    Toggle,
16    /// Start or resume playback
17    Play {
18        /// Play a specific Spotify URI (track, album, playlist, etc.)
19        #[arg(long, short = 'u')]
20        uri: Option<String>,
21        /// Play a pinned resource by alias
22        #[arg(long, short = 'p')]
23        pin: Option<String>,
24    },
25    /// Pause playback
26    Pause,
27    /// Get current playback status (alias: st)
28    #[command(alias = "st")]
29    Status {
30        /// Output only the ID (for piping): track, album, or artist
31        #[arg(long, value_parser = ["track", "album", "artist"])]
32        id_only: Option<String>,
33    },
34    /// Manage playback devices (alias: dev)
35    #[command(alias = "dev")]
36    Devices {
37        #[command(subcommand)]
38        command: DevicesCommand,
39    },
40    /// Manage playback queue (alias: q)
41    #[command(alias = "q")]
42    Queue {
43        #[command(subcommand)]
44        command: QueueCommand,
45    },
46    /// Seek to position in current track
47    Seek {
48        /// Position: seconds (90), time (1:30), or explicit (90s, 5000ms)
49        position: String,
50    },
51    /// Set repeat mode (alias: rep)
52    #[command(alias = "rep")]
53    Repeat {
54        /// Repeat mode: off, track, or context
55        #[arg(value_parser = ["off", "track", "context"])]
56        mode: String,
57    },
58    /// Set playback volume (alias: vol)
59    #[command(alias = "vol")]
60    Volume {
61        /// Volume percentage (0-100)
62        #[arg(value_parser = clap::value_parser!(u8).range(0..=100))]
63        percent: u8,
64    },
65    /// Toggle shuffle mode (alias: sh)
66    #[command(alias = "sh")]
67    Shuffle {
68        /// Shuffle state: on or off
69        #[arg(value_parser = ["on", "off"])]
70        state: String,
71    },
72    /// Get recently played tracks (alias: rec)
73    #[command(alias = "rec")]
74    Recent,
75}
76
77#[derive(Subcommand)]
78pub enum DevicesCommand {
79    /// List available devices
80    List,
81    /// Transfer playback to a device
82    Transfer {
83        /// Device ID or name
84        device: String,
85    },
86}
87
88#[derive(Subcommand)]
89pub enum QueueCommand {
90    /// List current queue (alias: ls)
91    #[command(alias = "ls")]
92    List,
93    /// Add item to queue
94    Add {
95        /// Spotify URI (e.g., spotify:track:xxx)
96        uri: Option<String>,
97        /// Add the currently playing track
98        #[arg(long, short = 'n')]
99        now_playing: bool,
100    },
101}