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]]
|
[[package]]
|
||||||
name = "noise"
|
name = "noise"
|
||||||
version = "0.1.0"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"libnotify",
|
"libnotify",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "noise"
|
name = "noise"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
46
src/main.rs
46
src/main.rs
|
@ -64,11 +64,16 @@ enum Commands {
|
||||||
append: bool,
|
append: bool,
|
||||||
},
|
},
|
||||||
/// List items in the current queueueu
|
/// List items in the current queueueu
|
||||||
List {},
|
List {
|
||||||
|
#[arg(short, long)]
|
||||||
|
file: bool,
|
||||||
|
},
|
||||||
// Add {
|
// Add {
|
||||||
// #[arg(short, long)]
|
// #[arg(short, long)]
|
||||||
// position: Option<u32>,
|
// position: Option<u32>,
|
||||||
// },
|
// },
|
||||||
|
/// Shuffles the current queueue
|
||||||
|
Shuffle {},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -84,7 +89,7 @@ fn main() {
|
||||||
|
|
||||||
// let mut conn = Client::connect(host).unwrap();
|
// 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) {
|
// let mut conn = match Client::connect(host) {
|
||||||
// Ok(conn) => conn,
|
// Ok(conn) => conn,
|
||||||
|
@ -95,13 +100,17 @@ fn main() {
|
||||||
match cmd {
|
match cmd {
|
||||||
Commands::Play { track } => {
|
Commands::Play { track } => {
|
||||||
if let Some(i) = track {
|
if let Some(i) = track {
|
||||||
conn.switch(*i).unwrap()
|
conn.switch(*i).unwrap();
|
||||||
} else {
|
} else {
|
||||||
conn.play().unwrap();
|
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 {} => {
|
Commands::Toggle {} => {
|
||||||
if conn.status().unwrap().state == State::Stop {
|
if conn.status().unwrap().state == State::Stop {
|
||||||
|
@ -125,7 +134,17 @@ fn main() {
|
||||||
println!("{status}");
|
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 {} => {
|
Commands::Update {} => {
|
||||||
let thing = conn.update().unwrap();
|
let thing = conn.update().unwrap();
|
||||||
|
@ -204,10 +223,13 @@ fn main() {
|
||||||
println!("Crossfade disabled")
|
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 {
|
} else {
|
||||||
let status = get_status(conn, cli.verbose, n);
|
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 {
|
fn format_song(song: Song) -> String {
|
||||||
format!("{} - {}", song.artist.unwrap(), song.title.unwrap())
|
format!("{} - {}", song.artist.unwrap(), song.title.unwrap())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue