From 91281038aa165330d455d091513a1adcc6da8b70 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 24 Jan 2022 09:31:25 -0600 Subject: [PATCH] fix(config): Update to TOML 1.0 Fixes #405 --- Cargo.lock | 21 +++++++++++++++++---- Cargo.toml | 2 +- src/bin/typos-cli/main.rs | 3 ++- src/config.rs | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8ca2c8..ad9e2e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "combine" -version = "4.6.2" +version = "4.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b2f5d0ee456f3928812dfc8c6d9a1d592b98678f6d56db9b0cd2b7bc6c8db5" +checksum = "50b727aacc797f9fc28e355d21f34709ac4fc9adecfe470ad07b8f4464f53062" dependencies = [ "bytes", "memchr", @@ -1477,6 +1477,19 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_edit" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b80ac5e1b91e3378c63dab121962472b5ca20cf9ab1975e3d588548717807a8" +dependencies = [ + "combine", + "indexmap", + "itertools", + "kstring", + "serde", +] + [[package]] name = "trycmd" version = "0.8.3" @@ -1494,7 +1507,7 @@ dependencies = [ "serde", "shlex", "tempfile", - "toml_edit", + "toml_edit 0.10.1", "wait-timeout", "walkdir", "yansi", @@ -1553,7 +1566,7 @@ dependencies = [ "proc-exit", "serde", "serde_json", - "toml", + "toml_edit 0.13.0", "trycmd", "typed-arena", "typos", diff --git a/Cargo.toml b/Cargo.toml index 4028334..1723899 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ clap = "3.0" clap-verbosity-flag = "0.4" ignore = "0.4" serde = { version = "1.0", features = ["derive"] } -toml = "0.5" +toml_edit = { version = "0.13.0", features = ["easy"] } log = "0.4" env_logger = { version = "0.9", default-features = false, features = ["termcolor"] } atty = "0.2.14" diff --git a/src/bin/typos-cli/main.rs b/src/bin/typos-cli/main.rs index 5052554..171a73e 100644 --- a/src/bin/typos-cli/main.rs +++ b/src/bin/typos-cli/main.rs @@ -85,7 +85,8 @@ fn run_dump_config(args: &args::Args, output_path: &std::path::Path) -> proc_exi let mut defaulted_config = typos_cli::config::Config::from_defaults(); defaulted_config.update(&config); - let output = toml::to_string_pretty(&defaulted_config).with_code(proc_exit::Code::FAILURE)?; + let output = + toml_edit::easy::to_string_pretty(&defaulted_config).with_code(proc_exit::Code::FAILURE)?; if output_path == std::path::Path::new("-") { std::io::stdout().write_all(output.as_bytes())?; } else { diff --git a/src/config.rs b/src/config.rs index ae099da..9ef790d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -31,7 +31,7 @@ impl Config { } pub fn from_toml(data: &str) -> Result { - let content = toml::from_str(data)?; + let content = toml_edit::easy::from_str(data)?; Ok(content) }