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 {
|
||||
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<String> = conn
|
||||
.queue()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|x| x.place.unwrap().pos.to_string())
|
||||
.collect();
|
||||
println!("{things:?}");
|
||||
println!("{}", conn.get_status(cli.verbose));
|
||||
}
|
||||
|
|
|
@ -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<String>, max: Option<u32>, append: bool);
|
||||
fn noise_search(&mut self, query: &Vec<String>, max: Option<u32>);
|
||||
fn noise_crossfade(&mut self, seconds: Option<i64>);
|
||||
fn noise_play(&mut self, track: Option<u32>);
|
||||
fn find(&mut self, query: &Vec<String>, max: Option<u32>, append: bool);
|
||||
fn search(&mut self, query: &Vec<String>, max: Option<u32>);
|
||||
fn crossfade(&mut self, seconds: Option<i64>);
|
||||
fn play(&mut self, track: Option<u32>);
|
||||
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<String>, max: Option<u32>, append: bool) {
|
||||
fn find(&mut self, query: &Vec<String>, max: Option<u32>, 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<String>, max: Option<u32>) {
|
||||
fn search(&mut self, query: &Vec<String>, max: Option<u32>) {
|
||||
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<i64>) {
|
||||
fn crossfade(&mut self, seconds: Option<i64>) {
|
||||
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<u32>) {
|
||||
fn play(&mut self, track: Option<u32>) {
|
||||
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 {
|
||||
|
|
|
@ -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<u32>,
|
||||
},
|
||||
/// Set or get crossfade
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue