Some finetuning

- Added 'shuffle' command
- Added more info to 'list' command
This commit is contained in:
Nox Sluijtman 2025-06-19 16:48:22 +02:00
parent 944c633792
commit cbf90ce5f0
Signed by: Egg
SSH key fingerprint: SHA256:2sG9X3C7Xvq2svGumz1/k7cm8l4G9+qAtAeugqB4J9M
3 changed files with 33 additions and 17 deletions

2
Cargo.lock generated
View file

@ -249,7 +249,7 @@ dependencies = [
[[package]]
name = "noise"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"clap",
"libnotify",

View file

@ -1,6 +1,6 @@
[package]
name = "noise"
version = "0.1.1"
version = "0.1.2"
edition = "2024"
[dependencies]

View file

@ -64,11 +64,16 @@ enum Commands {
append: bool,
},
/// List items in the current queueueu
List {},
List {
#[arg(short, long)]
file: bool,
},
// Add {
// #[arg(short, long)]
// position: Option<u32>,
// },
/// Shuffles the current queueue
Shuffle {},
}
fn main() {
@ -84,7 +89,7 @@ fn main() {
// let mut conn = Client::connect(host).unwrap();
let mut conn = Client::connect(host).expect("Things");
let mut conn = Client::connect(host).expect("Connection failed");
// let mut conn = match Client::connect(host) {
// Ok(conn) => conn,
@ -95,13 +100,17 @@ fn main() {
match cmd {
Commands::Play { track } => {
if let Some(i) = track {
conn.switch(*i).unwrap()
conn.switch(*i).unwrap();
} else {
conn.play().unwrap();
}
let status = get_status(conn, cli.verbose, n);
println!("{status}");
}
Commands::Stop {} => conn.stop().unwrap(),
Commands::Stop {} => {
conn.stop().unwrap();
}
Commands::Toggle {} => {
if conn.status().unwrap().state == State::Stop {
@ -125,7 +134,17 @@ fn main() {
println!("{status}");
}
Commands::List {} => print_songs(conn.queue().unwrap()),
Commands::List { file } => conn.queue().unwrap().iter().for_each(|x| {
println!(
"{:<02} {}",
x.place.unwrap().pos,
if *file {
x.file.clone()
} else {
format_song(x.clone())
}
)
}),
Commands::Update {} => {
let thing = conn.update().unwrap();
@ -204,10 +223,13 @@ fn main() {
println!("Crossfade disabled")
}
}
} // Commands::Add { position } => {
// // insert_or_append(conn, *position);
// println!("{:?}", position);
// }
}
Commands::Shuffle {} => {
send_notification("Shuffling queueueu...".to_string(), n);
println!("Shuffling queueueu...");
conn.shuffle(..).unwrap();
}
}
} else {
let status = get_status(conn, cli.verbose, n);
@ -216,12 +238,6 @@ fn main() {
}
}
fn print_songs(songs: Vec<Song>) -> () {
songs
.iter()
.for_each(|x| println!("{}", format_song(x.clone())));
}
fn format_song(song: Song) -> String {
format!("{} - {}", song.artist.unwrap(), song.title.unwrap())
}