diff --git a/Cargo.lock b/Cargo.lock index 861843b89f..69d535d6d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2566,6 +2566,15 @@ dependencies = [ "nom", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "notify" version = "4.0.17" @@ -2789,7 +2798,7 @@ dependencies = [ "terminal_size 0.2.1", "thiserror", "titlecase", - "toml", + "toml 0.7.1", "trash", "umask", "unicode-segmentation", @@ -4593,6 +4602,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -5259,6 +5277,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772c1426ab886e7362aedf4abc9c0d1348a979517efedfc25862944d10137af0" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90a238ee2e6ede22fb95350acc78e21dc40da00bb66c0334bde83de4ed89424e" +dependencies = [ + "indexmap", + "nom8", + "serde", + "serde_spanned", + "toml_datetime", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -5885,7 +5937,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" dependencies = [ - "toml", + "toml 0.5.9", ] [[package]] diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 5763bfac29..1ab0c9b1a8 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -86,7 +86,7 @@ sysinfo = "0.27.7" terminal_size = "0.2.1" thiserror = "1.0.31" titlecase = "2.0.0" -toml = "0.5.8" +toml = "0.7.1" unicode-segmentation = "1.8.0" url = "2.2.1" percent-encoding = "2.2.0" diff --git a/crates/nu-command/src/formats/from/toml.rs b/crates/nu-command/src/formats/from/toml.rs index 6214169737..4115be2d27 100644 --- a/crates/nu-command/src/formats/from/toml.rs +++ b/crates/nu-command/src/formats/from/toml.rs @@ -125,4 +125,40 @@ mod tests { test_examples(FromToml {}) } + + #[test] + fn string_to_toml_value_passes() { + let input_string = String::from( + r#" + command.build = "go build" + + [command.deploy] + script = "./deploy.sh" + "#, + ); + + let span = Span::test_data(); + + let result = convert_string_to_value(input_string, span); + + assert!(result.is_ok()); + } + + #[test] + fn string_to_toml_value_fails() { + let input_string = String::from( + r#" + command.build = + + [command.deploy] + script = "./deploy.sh" + "#, + ); + + let span = Span::test_data(); + + let result = convert_string_to_value(input_string, span); + + assert!(result.is_err()); + } }