tweag / nickel

Better configuration for less
https://nickel-lang.org/
MIT License
2.32k stars 88 forks source link

Multiformat export #1155

Closed N4tus closed 1 year ago

N4tus commented 1 year ago

A software-system, composed of multiple components, more than often requires configuration in different format for each component. Component A needs a yaml file and component B needs some json files. But since they are part of the same software-system these configurations probably share information and need to stay synchronized. If nickel for example would be able to export different parts of a record in different formats, one nickel configuration could be used for all configurations ensuring they stay synchronized.

In praxis such a feature would be more complex and only tacked in the far future, if ever, but I hope I got the idea across. It would also be a nice sales pitch: Nickel, one configuration for everything.

yannham commented 1 year ago

Currently Nickel is able to export to JSON, YAML, and TOML. So, you can already do something like:

$ nickel export --format JSON <<< '(import "config.ncl").part_A' > json_output.json
$ nickel export --format YAML <<< '(import "config.ncl").part_B' > yaml_output.yaml
$ nickel export --format TOML <<< '(import "config.ncl").part_C' > toml_output.toml

Thanks to laziness, only the things that are relevant to each part would be evaluated. Does this workflow suit your needs? Or are you thinking about something else?

yannham commented 1 year ago

Without further information, it's not clear what is missing currently, or what would be the scope and the motivation of a multiformat export feature. I'm closing for now: feel free to reopen if you have further comments and requests.