fix(config): Update to TOML 1.0

Fixes #405
This commit is contained in:
Ed Page 2022-01-24 09:31:25 -06:00
parent f7fd7c0e42
commit 91281038aa
4 changed files with 21 additions and 7 deletions

21
Cargo.lock generated
View file

@ -247,9 +247,9 @@ dependencies = [
[[package]] [[package]]
name = "combine" name = "combine"
version = "4.6.2" version = "4.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b2f5d0ee456f3928812dfc8c6d9a1d592b98678f6d56db9b0cd2b7bc6c8db5" checksum = "50b727aacc797f9fc28e355d21f34709ac4fc9adecfe470ad07b8f4464f53062"
dependencies = [ dependencies = [
"bytes", "bytes",
"memchr", "memchr",
@ -1477,6 +1477,19 @@ dependencies = [
"serde", "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]] [[package]]
name = "trycmd" name = "trycmd"
version = "0.8.3" version = "0.8.3"
@ -1494,7 +1507,7 @@ dependencies = [
"serde", "serde",
"shlex", "shlex",
"tempfile", "tempfile",
"toml_edit", "toml_edit 0.10.1",
"wait-timeout", "wait-timeout",
"walkdir", "walkdir",
"yansi", "yansi",
@ -1553,7 +1566,7 @@ dependencies = [
"proc-exit", "proc-exit",
"serde", "serde",
"serde_json", "serde_json",
"toml", "toml_edit 0.13.0",
"trycmd", "trycmd",
"typed-arena", "typed-arena",
"typos", "typos",

View file

@ -68,7 +68,7 @@ clap = "3.0"
clap-verbosity-flag = "0.4" clap-verbosity-flag = "0.4"
ignore = "0.4" ignore = "0.4"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
toml = "0.5" toml_edit = { version = "0.13.0", features = ["easy"] }
log = "0.4" log = "0.4"
env_logger = { version = "0.9", default-features = false, features = ["termcolor"] } env_logger = { version = "0.9", default-features = false, features = ["termcolor"] }
atty = "0.2.14" atty = "0.2.14"

View file

@ -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(); let mut defaulted_config = typos_cli::config::Config::from_defaults();
defaulted_config.update(&config); 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("-") { if output_path == std::path::Path::new("-") {
std::io::stdout().write_all(output.as_bytes())?; std::io::stdout().write_all(output.as_bytes())?;
} else { } else {

View file

@ -31,7 +31,7 @@ impl Config {
} }
pub fn from_toml(data: &str) -> Result<Self, anyhow::Error> { pub fn from_toml(data: &str) -> Result<Self, anyhow::Error> {
let content = toml::from_str(data)?; let content = toml_edit::easy::from_str(data)?;
Ok(content) Ok(content)
} }