From bd478ff64b9e0094610a54ca1a29d026af9d2496 Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Wed, 12 Oct 2022 08:11:16 +0530 Subject: [PATCH] Update serde_yaml to 0.9 --- Cargo.lock | 143 +++++++++++++++++++++++++++++++--------- Cargo.toml | 11 ++-- src/cli.rs | 2 +- src/msg/in_/external.rs | 15 +++++ src/pipe.rs | 4 +- 5 files changed, 134 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 966a854..6a1337c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,6 +185,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -295,6 +305,50 @@ dependencies = [ "winapi", ] +[[package]] +name = "cxx" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f39818dcfc97d45b03953c1292efc4e80954e1583c4aa770bac1383e2310a4" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e580d70777c116df50c390d1211993f62d40302881e54d4b79727acb83d0199" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56a46460b88d1cec95112c8c363f0e2c39afdb237f60583b0b36343bf627ea9c" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "difflib" version = "0.4.0" @@ -353,9 +407,9 @@ dependencies = [ [[package]] name = "gethostname" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" dependencies = [ "libc", "winapi", @@ -404,17 +458,28 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.50" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0" +checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed" dependencies = [ "android_system_properties", "core-foundation-sys", + "iana-time-zone-haiku", "js-sys", "wasm-bindgen", "winapi", ] +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde6edd6cef363e9359ed3c98ba64590ba9eecba2293eb5a723ab32aee8926aa" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "indexmap" version = "1.9.1" @@ -437,9 +502,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sys" @@ -458,9 +523,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.134" +version = "0.2.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" +checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" [[package]] name = "libm" @@ -469,10 +534,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "link-cplusplus" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] [[package]] name = "lock_api" @@ -562,9 +630,9 @@ dependencies = [ [[package]] name = "mlua" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10277581090f5cb7ecf814bc611152ce4db6dc8deffcaa08e24ed4c5197d9186" +checksum = "86b8fdab73969938b10159fb7e4fee45e96f386baadd8eaa6150e3161f28dfe2" dependencies = [ "bstr", "cc", @@ -837,6 +905,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + [[package]] name = "serde" version = "1.0.145" @@ -859,9 +933,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" dependencies = [ "itoa", "ryu", @@ -870,14 +944,15 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.26" +version = "0.9.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +checksum = "8613d593412a0deb7bbd8de9d908efff5a0cb9ccd8f62c641e7b2ed2f57291d1" dependencies = [ "indexmap", + "itoa", "ryu", "serde", - "yaml-rust", + "unsafe-libyaml", ] [[package]] @@ -918,15 +993,24 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "syn" -version = "1.0.101" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "termtree" version = "0.2.4" @@ -1024,9 +1108,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-segmentation" @@ -1040,6 +1124,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unsafe-libyaml" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e5fa573d8ac5f1a856f8d7be41d390ee973daf97c806b2c1a465e4e1406e68" + [[package]] name = "version_check" version = "0.9.4" @@ -1242,12 +1332,3 @@ 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 7c28584..9208e9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,19 +22,16 @@ categories = ['command-line-interface', 'command-line-utilities'] include = ['src/**/*', 'docs/en/src/**/*', 'LICENSE', 'README.md'] [dependencies] -libc = "0.2.134" +libc = "0.2.135" humansize = "2.1.0" natord = "1.0.9" anyhow = "1.0.65" - -# Let's keep this locked to 0.8.26. See https://docs.rs/serde_yaml/0.9.11/serde_yaml/ -serde_yaml = "0.8.26" - +serde_yaml = "0.9.13" crossterm = "0.25.0" dirs = "4.0.0" ansi-to-tui = "2.0.0" regex = "1.6.0" -gethostname = "0.2.3" +gethostname = "0.3.0" fuzzy-matcher = "0.3.7" [dependencies.lazy_static] @@ -63,7 +60,7 @@ version = "1.9.1" features = ['serde'] [dependencies.mlua] -version = "0.8.3" +version = "0.8.4" features = ['luajit', 'vendored', 'serialize', 'send'] [dependencies.tui-input] diff --git a/src/cli.rs b/src/cli.rs index 8473b2b..bb2be1a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -112,7 +112,7 @@ impl Cli { args.push_front(msg); break; } else { - cli.on_load.push(serde_yaml::from_str(&msg)?); + cli.on_load.push(msg.trim().try_into()?); } } } diff --git a/src/msg/in_/external.rs b/src/msg/in_/external.rs index 9aae1be..41ae01a 100644 --- a/src/msg/in_/external.rs +++ b/src/msg/in_/external.rs @@ -1063,6 +1063,21 @@ pub enum ExternalMsg { Terminate, } +impl TryFrom<&str> for ExternalMsg { + type Error = serde_yaml::Error; + + fn try_from(value: &str) -> Result { + if value.starts_with('!') { + serde_yaml::from_str(value) + } else if let Some((msg, args)) = value.split_once(' ') { + let msg = format!("!{} {}", msg.trim_end_matches(':'), args); + serde_yaml::from_str(&msg) + } else { + serde_yaml::from_str(value) + } + } +} + impl ExternalMsg { pub fn is_read_only(&self) -> bool { !matches!( diff --git a/src/pipe.rs b/src/pipe.rs index b9a6fdd..0724bde 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -67,8 +67,8 @@ pub fn read_all(pipe: &str) -> Result> { if !in_str.is_empty() { let mut msgs = vec![]; - for msg in in_str.lines().map(|s| serde_yaml::from_str(s.trim())) { - msgs.push(msg?); + for msg in in_str.lines() { + msgs.push(msg.trim().try_into()?); } Ok(msgs) } else {