Cleanup
This commit is contained in:
parent
a74c3d2a3d
commit
5556ea70df
3 changed files with 26 additions and 14 deletions
15
src/main.rs
15
src/main.rs
|
@ -33,7 +33,7 @@ fn main() {
|
||||||
|
|
||||||
if let Some(cmd) = &cli.command {
|
if let Some(cmd) = &cli.command {
|
||||||
match cmd {
|
match cmd {
|
||||||
Commands::Play { track } => conn.noise_play(*track),
|
Commands::Play { track } => Noise::play(&mut conn, *track),
|
||||||
Commands::Stop => conn.stop().unwrap(),
|
Commands::Stop => conn.stop().unwrap(),
|
||||||
Commands::Toggle => conn.toggle(),
|
Commands::Toggle => conn.toggle(),
|
||||||
Commands::Next => conn.next().unwrap(),
|
Commands::Next => conn.next().unwrap(),
|
||||||
|
@ -41,9 +41,9 @@ fn main() {
|
||||||
Commands::List { file } => conn.list_queue(*file, cli.verbose),
|
Commands::List { file } => conn.list_queue(*file, cli.verbose),
|
||||||
Commands::Current => (),
|
Commands::Current => (),
|
||||||
Commands::Clear => conn.clear().unwrap(),
|
Commands::Clear => conn.clear().unwrap(),
|
||||||
Commands::Search { query, max } => conn.noise_search(query, *max),
|
Commands::Search { query, max } => Noise::search(&mut conn, query, *max),
|
||||||
Commands::Find { query, max, append } => conn.noise_find(query, *max, *append),
|
Commands::Find { query, max, append } => Noise::find(&mut conn, query, *max, *append),
|
||||||
Commands::Crossfade { seconds } => conn.noise_crossfade(*seconds),
|
Commands::Crossfade { seconds } => Noise::crossfade(&mut conn, *seconds),
|
||||||
Commands::Shuffle => conn.shuf(),
|
Commands::Shuffle => conn.shuf(),
|
||||||
Commands::Repeat => conn.toggle_repeat(),
|
Commands::Repeat => conn.toggle_repeat(),
|
||||||
Commands::Random => conn.toggle_random(),
|
Commands::Random => conn.toggle_random(),
|
||||||
|
@ -65,5 +65,12 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let things: Vec<String> = conn
|
||||||
|
.queue()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|x| x.place.unwrap().pos.to_string())
|
||||||
|
.collect();
|
||||||
|
println!("{things:?}");
|
||||||
println!("{}", conn.get_status(cli.verbose));
|
println!("{}", conn.get_status(cli.verbose));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ use mpd::{Client, Query, Song, State, Term};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub trait Noise {
|
pub trait Noise {
|
||||||
fn noise_find(&mut self, query: &Vec<String>, max: Option<u32>, append: bool);
|
fn find(&mut self, query: &Vec<String>, max: Option<u32>, append: bool);
|
||||||
fn noise_search(&mut self, query: &Vec<String>, max: Option<u32>);
|
fn search(&mut self, query: &Vec<String>, max: Option<u32>);
|
||||||
fn noise_crossfade(&mut self, seconds: Option<i64>);
|
fn crossfade(&mut self, seconds: Option<i64>);
|
||||||
fn noise_play(&mut self, track: Option<u32>);
|
fn play(&mut self, track: Option<u32>);
|
||||||
fn toggle(&mut self);
|
fn toggle(&mut self);
|
||||||
fn munch(&mut self);
|
fn munch(&mut self);
|
||||||
fn length(&mut self);
|
fn length(&mut self);
|
||||||
|
@ -21,10 +21,11 @@ pub trait Noise {
|
||||||
fn shuf(&mut self);
|
fn shuf(&mut self);
|
||||||
fn get_status(&mut self, verbose: bool) -> String;
|
fn get_status(&mut self, verbose: bool) -> String;
|
||||||
fn list_queue(&mut self, file: bool, _verbose: bool);
|
fn list_queue(&mut self, file: bool, _verbose: bool);
|
||||||
|
// fn get_art(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Noise for Client {
|
impl Noise for Client {
|
||||||
fn noise_find(&mut self, query: &Vec<String>, max: Option<u32>, append: bool) {
|
fn find(&mut self, query: &Vec<String>, max: Option<u32>, append: bool) {
|
||||||
let query = query.join(" ");
|
let query = query.join(" ");
|
||||||
let max = max.unwrap_or(self.stats().unwrap().songs);
|
let max = max.unwrap_or(self.stats().unwrap().songs);
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ impl Noise for Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noise_search(&mut self, query: &Vec<String>, max: Option<u32>) {
|
fn search(&mut self, query: &Vec<String>, max: Option<u32>) {
|
||||||
let query = query.join(" ");
|
let query = query.join(" ");
|
||||||
let max = max.unwrap_or(self.stats().unwrap().songs);
|
let max = max.unwrap_or(self.stats().unwrap().songs);
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ impl Noise for Client {
|
||||||
.for_each(|x| println!("{}", x.file));
|
.for_each(|x| println!("{}", x.file));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noise_crossfade(&mut self, seconds: Option<i64>) {
|
fn crossfade(&mut self, seconds: Option<i64>) {
|
||||||
if let Some(seconds) = seconds {
|
if let Some(seconds) = seconds {
|
||||||
self.crossfade(seconds).unwrap();
|
self.crossfade(seconds).unwrap();
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +63,7 @@ impl Noise for Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noise_play(&mut self, track: Option<u32>) {
|
fn play(&mut self, track: Option<u32>) {
|
||||||
if let Some(i) = track {
|
if let Some(i) = track {
|
||||||
self.switch(i).unwrap();
|
self.switch(i).unwrap();
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,6 +186,11 @@ impl Noise for Client {
|
||||||
|
|
||||||
output.join("\n")
|
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 {
|
fn format_song(song: Song) -> String {
|
||||||
|
|
|
@ -40,9 +40,8 @@ pub enum Commands {
|
||||||
/// Stops playing
|
/// Stops playing
|
||||||
Stop,
|
Stop,
|
||||||
/// Play queueueu
|
/// Play queueueu
|
||||||
#[command(visible_alias = "start")]
|
|
||||||
Play {
|
Play {
|
||||||
#[arg(value_hint = ValueHint::Other)]
|
#[arg(value_hint = ValueHint::CommandString)]
|
||||||
track: Option<u32>,
|
track: Option<u32>,
|
||||||
},
|
},
|
||||||
/// Set or get crossfade
|
/// Set or get crossfade
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue