diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-05 22:59:43 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-05 22:59:43 +0200 |
| commit | 6a5aef96b08c4e842033a4c34c6261d2bbcb7651 (patch) | |
| tree | a328ee46bdee427d852158d26fc50b5b7df757fa /src/cli.rs | |
| parent | Add metadata extraction and display for folder playback (diff) | |
| download | rsplayer-6a5aef96b08c4e842033a4c34c6261d2bbcb7651.tar.gz rsplayer-6a5aef96b08c4e842033a4c34c6261d2bbcb7651.zip | |
Add flexible play command with position flags
- Add -i/--now, -n/--next, -l/--last flags to play command:
- 'play MUSIC' (default) adds to end of queue and plays
- 'play -i MUSIC' inserts after current and skips to it
- 'play -n MUSIC' inserts after current, doesn't skip
- 'play -l MUSIC' adds to end of queue (default behavior)
- Add insert_after_current and track_at methods to Queue in daemon
- Update play command handler to handle position arguments
- Fix queue display to correctly show playing track (compare track_idx
instead of display_idx with current_position)
Diffstat (limited to '')
| -rw-r--r-- | src/cli.rs | 22 |
1 files changed, 20 insertions, 2 deletions
| @@ -21,6 +21,15 @@ pub enum Commands { | |||
| 21 | Restart, | 21 | Restart, |
| 22 | /// Play a track, album, or artist | 22 | /// Play a track, album, or artist |
| 23 | Play { | 23 | Play { |
| 24 | /// Play immediately (add after current and skip to it) | ||
| 25 | #[arg(short = 'i', long = "now", group = "position")] | ||
| 26 | now: bool, | ||
| 27 | /// Add to queue after current track (don't skip) | ||
| 28 | #[arg(short = 'n', long = "next", group = "position")] | ||
| 29 | next: bool, | ||
| 30 | /// Add to end of queue (default) | ||
| 31 | #[arg(short = 'l', long = "last", group = "position")] | ||
| 32 | last: bool, | ||
| 24 | #[arg(value_name = "QUERY")] | 33 | #[arg(value_name = "QUERY")] |
| 25 | query: Option<String>, | 34 | query: Option<String>, |
| 26 | }, | 35 | }, |
| @@ -102,9 +111,18 @@ impl Cli { | |||
| 102 | Commands::Restart => { | 111 | Commands::Restart => { |
| 103 | crate::daemon::restart_daemon()?; | 112 | crate::daemon::restart_daemon()?; |
| 104 | } | 113 | } |
| 105 | Commands::Play { query } => { | 114 | Commands::Play { |
| 115 | now, next, query, .. | ||
| 116 | } => { | ||
| 106 | if let Some(q) = query { | 117 | if let Some(q) = query { |
| 107 | crate::daemon::send_command(format!("play {}", q))?; | 118 | let pos = if *now { |
| 119 | "now" | ||
| 120 | } else if *next { | ||
| 121 | "next" | ||
| 122 | } else { | ||
| 123 | "last" | ||
| 124 | }; | ||
| 125 | crate::daemon::send_command(format!("play {} {}", pos, q))?; | ||
| 108 | } else { | 126 | } else { |
| 109 | crate::daemon::send_command("play".to_string())?; | 127 | crate::daemon::send_command("play".to_string())?; |
| 110 | } | 128 | } |
