From 7103b78d38c366b60fa3fbbef0afbec154a8c391 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sun, 26 Mar 2023 00:59:15 +0100 Subject: [PATCH] Draft: Toml (#1439) * toml wip * wip * Fixed auto parsing toml * Added build flag not to include toml * Parse toml docs and tests * minor updates --- .gitignore | 2 + acceptance_tests/inputs-format-auto.sh | 21 ++ cmd/root.go | 4 +- cmd/utils.go | 5 + examples/sample.toml | 26 ++ go.mod | 1 + go.sum | 12 +- pkg/yqlib/data_tree_navigator.go | 24 ++ pkg/yqlib/decoder.go | 5 +- pkg/yqlib/decoder_properties.go | 18 +- pkg/yqlib/decoder_test.go | 3 +- pkg/yqlib/decoder_toml.go | 369 +++++++++++++++++++++++++ pkg/yqlib/doc/usage/headers/toml.md | 4 + pkg/yqlib/doc/usage/toml.md | 111 ++++++++ pkg/yqlib/no_toml.go | 7 + pkg/yqlib/toml_test.go | 239 ++++++++++++++++ 16 files changed, 828 insertions(+), 23 deletions(-) create mode 100644 examples/sample.toml create mode 100644 pkg/yqlib/decoder_toml.go create mode 100644 pkg/yqlib/doc/usage/headers/toml.md create mode 100644 pkg/yqlib/doc/usage/toml.md create mode 100644 pkg/yqlib/no_toml.go create mode 100644 pkg/yqlib/toml_test.go diff --git a/.gitignore b/.gitignore index b159f65d..aef9fba2 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,8 @@ yq*.snap test.yml test*.yml +test*.xml +test*.toml test*.yaml 0.yml 1.yml diff --git a/acceptance_tests/inputs-format-auto.sh b/acceptance_tests/inputs-format-auto.sh index a5e6897c..3c241d65 100755 --- a/acceptance_tests/inputs-format-auto.sh +++ b/acceptance_tests/inputs-format-auto.sh @@ -2,6 +2,7 @@ setUp() { rm test*.yml 2>/dev/null || true + rm test*.toml 2>/dev/null || true rm test*.tfstate 2>/dev/null || true rm test*.json 2>/dev/null || true rm test*.properties 2>/dev/null || true @@ -30,6 +31,26 @@ EOM assertEquals "$expected" "$X" } +testInputToml() { + cat >test.toml <test.tfstate <