From 6a5aef96b08c4e842033a4c34c6261d2bbcb7651 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 5 May 2026 22:59:43 +0200 Subject: 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) --- src/cli.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 13ef67c..1d83262 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -21,6 +21,15 @@ pub enum Commands { Restart, /// Play a track, album, or artist Play { + /// Play immediately (add after current and skip to it) + #[arg(short = 'i', long = "now", group = "position")] + now: bool, + /// Add to queue after current track (don't skip) + #[arg(short = 'n', long = "next", group = "position")] + next: bool, + /// Add to end of queue (default) + #[arg(short = 'l', long = "last", group = "position")] + last: bool, #[arg(value_name = "QUERY")] query: Option, }, @@ -102,9 +111,18 @@ impl Cli { Commands::Restart => { crate::daemon::restart_daemon()?; } - Commands::Play { query } => { + Commands::Play { + now, next, query, .. + } => { if let Some(q) = query { - crate::daemon::send_command(format!("play {}", q))?; + let pos = if *now { + "now" + } else if *next { + "next" + } else { + "last" + }; + crate::daemon::send_command(format!("play {} {}", pos, q))?; } else { crate::daemon::send_command("play".to_string())?; } -- cgit v1.2.3