From d730c3c72de22f08a5b09e40c9e61ae8c3b87ce7 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 29 Feb 2024 17:35:40 -0800 Subject: [PATCH] feat(config): support parsing json w/ comments This commit switches out the serde_json crate with the serde_json_lenient crate, forked by Google, which allows for JSON files with comments to be parsed properly. Users can set the format of komorebi.json to "jsonc" in their editors in order to write // comments without being faced with lint errors. The expected file extension remains the same (json). komorebi and komorebic will not look for files with the "jsonc" file extension or any other JSON-variant file extension. resolve #693 --- Cargo.lock | 19 +++++++++++++++---- Cargo.toml | 1 + komorebi-client/Cargo.toml | 2 +- komorebi-core/Cargo.toml | 2 +- komorebi/Cargo.toml | 2 +- komorebi/src/window.rs | 2 +- komorebic/Cargo.toml | 2 +- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 360370c4..9a8207ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -779,7 +779,7 @@ dependencies = [ "regex", "schemars", "serde", - "serde_json", + "serde_json_lenient", "strum", "sysinfo", "tracing", @@ -801,7 +801,7 @@ version = "0.1.22-dev.0" dependencies = [ "komorebi", "komorebi-core", - "serde_json", + "serde_json_lenient", "uds_windows", ] @@ -815,7 +815,7 @@ dependencies = [ "dunce", "schemars", "serde", - "serde_json", + "serde_json_lenient", "serde_yaml", "strum", "windows 0.54.0", @@ -839,7 +839,7 @@ dependencies = [ "powershell_script", "reqwest", "serde", - "serde_json", + "serde_json_lenient", "serde_yaml", "sysinfo", "thiserror", @@ -1650,6 +1650,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_json_lenient" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc61c66b53a4035fcce237ef38043f4b2f0ebf918fd0e69541a5166104065581" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" diff --git a/Cargo.toml b/Cargo.toml index 767f503e..68242582 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ windows-implement = { version = "0.53" } dunce = "1" dirs = "5" color-eyre = "0.6" +serde_json = { package = "serde_json_lenient", version = "0.1" } [workspace.dependencies.windows] version = "0.54" diff --git a/komorebi-client/Cargo.toml b/komorebi-client/Cargo.toml index 3ce29195..d0a2f0fa 100644 --- a/komorebi-client/Cargo.toml +++ b/komorebi-client/Cargo.toml @@ -9,4 +9,4 @@ edition = "2021" komorebi = { path = "../komorebi" } komorebi-core = { path = "../komorebi-core" } uds_windows = "1" -serde_json = "1" +serde_json = { workspace = true } diff --git a/komorebi-core/Cargo.toml b/komorebi-core/Cargo.toml index 9cbcf645..403b63de 100644 --- a/komorebi-core/Cargo.toml +++ b/komorebi-core/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] clap = { version = "4", features = ["derive"] } serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde_json = { workspace = true } serde_yaml = "0.9" strum = { version = "0.26", features = ["derive"] } schemars = "0.8" diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index da8389dd..6759b337 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -33,7 +33,7 @@ paste = "1" regex = "1" schemars = "0.8" serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde_json = { workspace = true } strum = { version = "0.26", features = ["derive"] } sysinfo = "0.30" tracing = "0.1" diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 6f4d3809..0ab56e0d 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -463,7 +463,7 @@ fn window_is_eligible( title: &String, exe_name: &String, class: &String, - path: &String, + path: &str, style: &WindowStyle, ex_style: &ExtendedWindowStyle, event: Option, diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index 5435d5f1..762fc120 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -26,7 +26,7 @@ paste = "1" powershell_script = "1.0" reqwest = { version = "0.11", features = ["blocking"] } serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde_json = { workspace = true } serde_yaml = "0.9" sysinfo = "0.30" thiserror = "1"