diff --git a/Cargo.lock b/Cargo.lock index a8bd985..a425105 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,6 +455,12 @@ version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "lock_api" version = "0.4.8" @@ -855,15 +861,14 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.11" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89f31df3f50926cdf2855da5fd8812295c34752cb20438dae42a67f79e021ac3" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ "indexmap", - "itoa 1.0.3", "ryu", "serde", - "unsafe-libyaml", + "yaml-rust", ] [[package]] @@ -1020,12 +1025,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unsafe-libyaml" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931179334a56395bcf64ba5e0ff56781381c1a5832178280c7d7f91d1679aeb0" - [[package]] name = "version_check" version = "0.9.4" @@ -1227,3 +1226,12 @@ dependencies = [ "tui", "tui-input", ] + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] diff --git a/Cargo.toml b/Cargo.toml index 8730c72..db12796 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,10 @@ libc = "0.2.132" humansize = "1.1.1" natord = "1.0.9" anyhow = "1.0.64" -serde_yaml = "0.9.11" + +# Let's keep this locked. See https://docs.rs/serde_yaml/0.9.11/serde_yaml/ +serde_yaml = "0.8.26" + crossterm = "0.25.0" dirs = "4.0.0" ansi-to-tui = "1.0.1" diff --git a/src/bin/xplr.rs b/src/bin/xplr.rs index 3691136..cd1964f 100644 --- a/src/bin/xplr.rs +++ b/src/bin/xplr.rs @@ -142,42 +142,42 @@ mod tests { .stderr(""); } - // TODO: Fix running GitHub action + // TODO fix GitHub CI failures // // #[test] // fn test_cli_path_arg_valid() { // Command::cargo_bin("xplr") // .unwrap() - // .arg("/tmp") + // .arg("src") // .arg("--on-load") // .arg("PrintResultAndQuit") // .assert() // .success() // .code(0) // .stderr(""); - + // // Command::cargo_bin("xplr") // .unwrap() - // .arg("/tmp") + // .arg("src") // .arg("--on-load") // .arg("PrintResultAndQuit") // .assert() // .success() // .code(0) // .stderr(""); - + // // Command::cargo_bin("xplr") // .unwrap() // .arg("--on-load") // .arg("PrintResultAndQuit") // .arg("--") - // .arg("/tmp") + // .arg("src") // .assert() // .success() // .code(0) // .stderr(""); // } - + // // #[test] // fn test_cli_path_stdin_valid() { // Command::cargo_bin("xplr") @@ -185,10 +185,25 @@ mod tests { // .arg("-") // .arg("--on-load") // .arg("PrintResultAndQuit") - // .write_stdin("/tmp\n") + // .write_stdin("src\n") // .assert() // .success() // .code(0) // .stderr(""); // } + // + // #[test] + // fn test_on_load_yaml_parsing() { + // Command::cargo_bin("xplr") + // .unwrap() + // .arg("--on-load") + // .arg("Call: {command: touch, args: [foo]}") + // .arg("Quit") + // .assert() + // .success() + // .code(0) + // .stderr(""); + // + // std::fs::remove_file("foo").unwrap(); + // } } diff --git a/src/msg/in_/external.rs b/src/msg/in_/external.rs index 0dab479..8442d82 100644 --- a/src/msg/in_/external.rs +++ b/src/msg/in_/external.rs @@ -1423,8 +1423,16 @@ impl PartialEq for CmpRegex { impl Eq for CmpRegex {} -#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] +// See https://github.com/sayanarijit/xplr/issues/503 +#[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] +struct NodeFilterApplicableDeserializer { + pub filter: NodeFilter, + pub input: String, +} + +#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields, from = "NodeFilterApplicableDeserializer")] pub struct NodeFilterApplicable { pub filter: NodeFilter, pub input: String, @@ -1433,6 +1441,12 @@ pub struct NodeFilterApplicable { pub regex: Option, } +impl From for NodeFilterApplicable { + fn from(f: NodeFilterApplicableDeserializer) -> Self { + NodeFilterApplicable::new(f.filter, f.input) + } +} + impl NodeFilterApplicable { pub fn new(filter: NodeFilter, input: String) -> Self { use NodeFilter::*;