-
-
Notifications
You must be signed in to change notification settings - Fork 754
Description
v4.52.4
Please describe your feature request.
I wish yq would prefer readable TOML tables instead of collapsing structures into the { ... } hash table form when emitting TOML.
TOML exists primarily for human readable configuration. The spec describes TOML as:
"A config file format for humans. TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics."
When yq converts data and emits TOML, it sometimes collapses structures into the compact hash table form. While valid TOML, this makes configuration files harder to read and scan. The hierarchy becomes compressed into a single line.
For example, if we have data.toml:
[arg]
hello = "foo"and run:
yq data.toml -oy | yq -o tomlthe output becomes:
arg = { hello = "foo" }This is technically correct TOML, but it works against the main reason people choose TOML for configuration, readability.
Most TOML in the ecosystem uses section headers because they make structure obvious and diffs easier to read.
Describe the solution you'd like
Prefer emitting standard TOML tables when serializing structures.
For example, given:
arg:
hello: fooRunning:
yq -o tomlshould output:
[arg]
hello = "foo"instead of collapsing the structure into the compact hash table form.
Describe alternatives you've considered
Currently the only way to reliably keep readable TOML output is to avoid certain transformations or avoid round tripping through YAML.
For example:
yq data.toml -otomlpreserves the table structure, but a YAML round trip:
yq data.toml -oy | yq -o tomldoes not.
Another option would be a flag to control this behavior, but preferring readable tables by default would better match TOML’s goal as a human focused configuration format.
Additional context
TOML was explicitly designed for human readable configuration files. Collapsing structures into { ... } hash tables reduces the visual structure that table headers provide and makes large configs harder to review and maintain.