Some finetuning
- Added 'shuffle' command - Added more info to 'list' command
This commit is contained in:
parent
944c633792
commit
cbf90ce5f0
3 changed files with 33 additions and 17 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -249,7 +249,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "noise"
|
||||
version = "0.1.0"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"libnotify",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "noise"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
|
46
src/main.rs
46
src/main.rs
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue