diff options
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 | } |
