Open thomasdfischer opened 6 years ago
This is a difficult problem to solve in an elegant way.
Is there a reason that you also change the ordering of it to be alphabetical instead of preserving order? Is it a config file style guideline?
Is there a reason why you'd want to support this? As long as the output format is nice it shouldn't matter to the user, could functionally be a beautifier for a lot of dirty settings. Comments may be useful to preserve though
I feel like theres use cases of config files where you have your config file setup so that things are ordered in a certain way so its easier to read or for grouping.
Perhaps adding support for something like namespaces can help preserve groupings without modifying the config itself
Example
Template:
Mark that as a template. Then, run
cfg new entry-addr entry-addr-local.json
. You'll see the output does not preserve spacing. Also, the fields are sorted alphabetically.