diff --git a/src/main.rs b/src/main.rs index bc9d85f..cc9bf03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ fn main() { if let Some(cmd) = &cli.command { match cmd { - Commands::Play { track } => conn.noise_play(*track), + Commands::Play { track } => Noise::play(&mut conn, *track), Commands::Stop => conn.stop().unwrap(), Commands::Toggle => conn.toggle(), Commands::Next => conn.next().unwrap(), @@ -41,9 +41,9 @@ fn main() { Commands::List { file } => conn.list_queue(*file, cli.verbose), Commands::Current => (), Commands::Clear => conn.clear().unwrap(), - Commands::Search { query, max } => conn.noise_search(query, *max), - Commands::Find { query, max, append } => conn.noise_find(query, *max, *append), - Commands::Crossfade { seconds } => conn.noise_crossfade(*seconds), + Commands::Search { query, max } => Noise::search(&mut conn, query, *max), + Commands::Find { query, max, append } => Noise::find(&mut conn, query, *max, *append), + Commands::Crossfade { seconds } => Noise::crossfade(&mut conn, *seconds), Commands::Shuffle => conn.shuf(), Commands::Repeat => conn.toggle_repeat(), Commands::Random => conn.toggle_random(), @@ -65,5 +65,12 @@ fn main() { return; } } + let things: Vec = conn + .queue() + .unwrap() + .iter() + .map(|x| x.place.unwrap().pos.to_string()) + .collect(); + println!("{things:?}"); println!("{}", conn.get_status(cli.verbose)); } diff --git a/src/noise/commands.rs b/src/noise/commands.rs index 1696ef1..c77eff9 100644 --- a/src/noise/commands.rs +++ b/src/noise/commands.rs @@ -6,10 +6,10 @@ use mpd::{Client, Query, Song, State, Term}; use std::time::Duration; pub trait Noise { - fn noise_find(&mut self, query: &Vec, max: Option, append: bool); - fn noise_search(&mut self, query: &Vec, max: Option); - fn noise_crossfade(&mut self, seconds: Option); - fn noise_play(&mut self, track: Option); + fn find(&mut self, query: &Vec, max: Option, append: bool); + fn search(&mut self, query: &Vec, max: Option); + fn crossfade(&mut self, seconds: Option); + fn play(&mut self, track: Option); fn toggle(&mut self); fn munch(&mut self); fn length(&mut self); @@ -21,10 +21,11 @@ pub trait Noise { fn shuf(&mut self); fn get_status(&mut self, verbose: bool) -> String; fn list_queue(&mut self, file: bool, _verbose: bool); + // fn get_art(&mut self); } impl Noise for Client { - fn noise_find(&mut self, query: &Vec, max: Option, append: bool) { + fn find(&mut self, query: &Vec, max: Option, append: bool) { let query = query.join(" "); let max = max.unwrap_or(self.stats().unwrap().songs); @@ -38,7 +39,7 @@ impl Noise for Client { } } - fn noise_search(&mut self, query: &Vec, max: Option) { + fn search(&mut self, query: &Vec, max: Option) { let query = query.join(" "); let max = max.unwrap_or(self.stats().unwrap().songs); @@ -48,7 +49,7 @@ impl Noise for Client { .for_each(|x| println!("{}", x.file)); } - fn noise_crossfade(&mut self, seconds: Option) { + fn crossfade(&mut self, seconds: Option) { if let Some(seconds) = seconds { self.crossfade(seconds).unwrap(); } else { @@ -62,7 +63,7 @@ impl Noise for Client { } } - fn noise_play(&mut self, track: Option) { + fn play(&mut self, track: Option) { if let Some(i) = track { self.switch(i).unwrap(); } else { @@ -185,6 +186,11 @@ impl Noise for Client { output.join("\n") } + + // fn get_art(&mut self) { + // let current_song = self.currentsong().unwrap().unwrap().file; + // self.albumart(¤t_song).unwrap(); + // } } fn format_song(song: Song) -> String { diff --git a/src/noise/parser.rs b/src/noise/parser.rs index 4505ae6..587a95d 100644 --- a/src/noise/parser.rs +++ b/src/noise/parser.rs @@ -40,9 +40,8 @@ pub enum Commands { /// Stops playing Stop, /// Play queueueu - #[command(visible_alias = "start")] Play { - #[arg(value_hint = ValueHint::Other)] + #[arg(value_hint = ValueHint::CommandString)] track: Option, }, /// Set or get crossfade