From 2bec331700a8c5f6fb28bf0d48e5984069d43eb8 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Fri, 15 Jul 2022 16:17:24 -0400 Subject: [PATCH] Improve REPL prompt and update deps --- Cargo.lock | 143 +++++++++++-------- bliss-rs | 2 +- interpreter/Cargo.toml | 2 +- interpreter/src/processing/music_analysis.rs | 8 +- src/repl.rs | 19 ++- 5 files changed, 104 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce1da09..2cf20bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ "peeking_take_while", "proc-macro2", "quote", - "regex 1.5.6", + "regex 1.6.0", "rustc-hash", "shlex", ] @@ -143,7 +143,7 @@ dependencies = [ [[package]] name = "bliss-audio-symphonia" -version = "0.4.6" +version = "0.5.0" dependencies = [ "anyhow", "bliss-audio-aubio-rs", @@ -159,7 +159,9 @@ dependencies = [ "ndarray-stats", "noisy_float", "num_cpus", + "pretty_assertions", "rayon", + "rcue", "ripemd160", "rustfft", "serde", @@ -232,9 +234,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" +checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a" [[package]] name = "byteorder" @@ -271,12 +273,9 @@ dependencies = [ [[package]] name = "cast" -version = "0.2.7" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" -dependencies = [ - "rustc_version", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" @@ -346,9 +345,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.8" +version = "3.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" +checksum = "ab8b79fe3946ceb4a0b1c080b4018992b8d27e9ff363644c1c9b6387c854614d" dependencies = [ "atty", "bitflags", @@ -408,7 +407,7 @@ dependencies = [ "encode_unicode", "libc", "once_cell", - "regex 1.5.6", + "regex 1.6.0", "terminal_size", "unicode-width", "winapi 0.3.9", @@ -475,9 +474,9 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", @@ -490,7 +489,7 @@ dependencies = [ "oorandom", "plotters", "rayon", - "regex 1.5.6", + "regex 1.6.0", "serde", "serde_cbor", "serde_derive", @@ -501,9 +500,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", "itertools", @@ -600,6 +599,16 @@ dependencies = [ "memchr 2.5.0", ] +[[package]] +name = "ctor" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "darling" version = "0.13.4" @@ -645,6 +654,12 @@ dependencies = [ "libdbus-sys", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.8.1" @@ -734,7 +749,7 @@ dependencies = [ "atty", "humantime", "log", - "regex 1.5.6", + "regex 1.6.0", "termcolor", ] @@ -875,9 +890,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" +checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022" [[package]] name = "hashlink" @@ -937,7 +952,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown 0.12.1", + "hashbrown 0.12.2", ] [[package]] @@ -1232,7 +1247,7 @@ dependencies = [ name = "muss" version = "0.9.0" dependencies = [ - "clap 3.2.8", + "clap 3.2.12", "console", "lazy_static 1.4.0", "muss-interpreter", @@ -1248,7 +1263,7 @@ dependencies = [ "dirs", "mpd", "rand", - "regex 1.5.6", + "regex 1.6.0", "rusqlite", "shellexpand", "symphonia 0.5.0", @@ -1259,7 +1274,7 @@ dependencies = [ name = "muss-m3u8" version = "0.9.0" dependencies = [ - "clap 3.2.8", + "clap 3.2.12", "m3u8-rs", "muss-interpreter", ] @@ -1553,9 +1568,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "oorandom" @@ -1581,6 +1596,15 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "parking_lot" version = "0.11.2" @@ -1663,9 +1687,9 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "9428003b84df1496fb9d6eeee9c5f8145cb41ca375eb0dad204328888832811f" dependencies = [ "num-traits", "plotters-backend", @@ -1676,15 +1700,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "e0918736323d1baff32ee0eade54984f6f201ad7e97d5cfb5d6ab4a358529615" dependencies = [ "plotters-backend", ] @@ -1695,6 +1719,18 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "pretty_assertions" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563" +dependencies = [ + "ansi_term", + "ctor", + "diff", + "output_vt100", +] + [[package]] name = "primal-check" version = "0.3.1" @@ -1829,6 +1865,12 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "rcue" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca1481d62f18158646de2ec552dd63f8bdc5be6448389b192ba95c939df997e" + [[package]] name = "redox_syscall" version = "0.2.13" @@ -1864,13 +1906,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.6" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick 0.7.18", "memchr 2.5.0", - "regex-syntax 0.6.26", + "regex-syntax 0.6.27", ] [[package]] @@ -1887,9 +1929,9 @@ checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "ripemd160" @@ -1943,15 +1985,6 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustfft" version = "5.1.1" @@ -1987,17 +2020,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d92beeab217753479be2f74e54187a6aed4c125ff0703a866c3147a02f0c6dd" - [[package]] name = "serde" -version = "1.0.137" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" dependencies = [ "serde_derive", ] @@ -2014,9 +2041,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" dependencies = [ "proc-macro2", "quote", @@ -2585,9 +2612,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" [[package]] name = "unicase" diff --git a/bliss-rs b/bliss-rs index 5d66e10..851da65 160000 --- a/bliss-rs +++ b/bliss-rs @@ -1 +1 @@ -Subproject commit 5d66e104235479e38f7bfef6d27980a183ff2142 +Subproject commit 851da65fcf4ca8f1081d121c27d5bbf919ce4861 diff --git a/interpreter/Cargo.toml b/interpreter/Cargo.toml index f92ac5f..f4c7d61 100644 --- a/interpreter/Cargo.toml +++ b/interpreter/Cargo.toml @@ -15,7 +15,7 @@ dirs = { version = "4" } regex = { version = "1" } rand = { version = "0.8" } shellexpand = { version = "2", optional = true } -bliss-audio-symphonia = { version = "0.4", optional = true, path = "../bliss-rs" } +bliss-audio-symphonia = { version = "0.5", optional = true, path = "../bliss-rs" } mpd = { version = "0.0.12", optional = true } unidecode = { version = "0.3.0", optional = true } diff --git a/interpreter/src/processing/music_analysis.rs b/interpreter/src/processing/music_analysis.rs index c6c46ae..d9f79b9 100644 --- a/interpreter/src/processing/music_analysis.rs +++ b/interpreter/src/processing/music_analysis.rs @@ -498,7 +498,7 @@ impl CacheThread { } } else { if !self.song_in_progress.contains(&path) { - // every song is roughly 2 threads -- Song::new(...) spawns a thread + // every song is roughly 2 threads -- Song::from_path(...) spawns a thread let available_parallelism = std::thread::available_parallelism().ok().map(|x| x.get()).unwrap_or(DEFAULT_PARALLELISM) / 2; let available_parallelism = if available_parallelism != 0 { @@ -535,7 +535,7 @@ impl CacheThread { let path_clone = path.clone(); let results = worker_tx.clone(); std::thread::spawn(move || { - let song_result = Song::new(&path_clone); + let song_result = Song::from_path(&path_clone); results .send(ResponseType::Song { path: path_clone, @@ -620,7 +620,7 @@ fn worker_distance( let song1 = if let Some(song) = song1.1 { song } else { - let new_song1 = Song::new(path1); + let new_song1 = Song::from_path(path1); results .send(ResponseType::Song { path: path1.to_string(), @@ -633,7 +633,7 @@ fn worker_distance( let song2 = if let Some(song) = song2.1 { song } else { - let new_song2 = Song::new(path2); + let new_song2 = Song::from_path(path2); results .send(ResponseType::Song { path: path2.to_string(), diff --git a/src/repl.rs b/src/repl.rs index dbbf0e0..3399264 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -91,23 +91,30 @@ fn interpreter_event_callback<'a, T: muss_interpreter::tokens::TokenReader>(_int Ok(()) } +#[inline] +fn item_prompt(terminal: &mut Term, args: &CliArgs) { + write!(terminal, "*I{}", args.prompt) + .expect(TERMINAL_WRITE_ERROR); +} + fn pretty_print_item(item: &Item, terminal: &mut Term, args: &CliArgs, verbose: bool) { + item_prompt(terminal, args); if verbose { - writeln!(terminal, "I{}--\\/-- `{}` --\\/--", args.prompt, + writeln!(terminal, "--\\/-- `{}` --\\/--", item.field("title").unwrap_or(&TypePrimitive::Empty).as_str() ).expect(TERMINAL_WRITE_ERROR); let mut fields: Vec<&_> = item.iter().collect(); fields.sort(); for field in fields { if field != "title" { - writeln!(terminal, "I{} {}: `{}`", - args.prompt, field, + writeln!(terminal, " {}: `{}`", + field, item.field(field).unwrap_or(&TypePrimitive::Empty).as_str() ).expect(TERMINAL_WRITE_ERROR); } } } else { - writeln!(terminal, "I{}`{}` by `{}`", args.prompt, + writeln!(terminal, "`{}` by `{}`", item.field("title").unwrap_or(&TypePrimitive::Empty).as_str(), item.field("artist").unwrap_or(&TypePrimitive::Empty).as_str(), ).expect(TERMINAL_WRITE_ERROR); @@ -614,7 +621,7 @@ fn read_loop(args: &CliArgs, state: &mut Rep #[inline(always)] fn prompt(state: &mut ReplState, args: &CliArgs) { - write!(state.terminal, "{}{}", state.line_number, args.prompt) + write!(state.terminal, "{: >2}{}", state.line_number, args.prompt) .expect(TERMINAL_WRITE_ERROR); state.line_number += 1; state @@ -649,7 +656,7 @@ fn display_history_line(state: &mut ReplState, args: &CliArgs) { #[inline(always)] fn error_prompt(error: muss_player::PlayerError, args: &CliArgs) { - eprintln!("E{}{}", args.prompt, error); + eprintln!("*E{}{}", args.prompt, error); } fn repl_commands(command_str: &str, state: &mut ReplState, _args: &CliArgs) {