Confbase / cfg

A tool to manage configuration files and use them in production.
https://confbase.com/cfg
Apache License 2.0
7 stars 6 forks source link

preserve spacing between template and instance #48

Open thomasdfischer opened 6 years ago

thomasdfischer commented 6 years ago

Example

Template:

{
    "protocol": "http://",
    "host_sans_protocol": "localhost",
    "port": 5000,

    "bundle_protocol": "http://",
    "bundle_host_sans_protocol": "localhost",
    "bundle_port": 2999
}

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.

{
    "bundle_host_sans_protocol": "",
    "bundle_port": 0,
    "bundle_protocol": "",
    "host_sans_protocol": "",
    "port": 0,
    "protocol": ""
}
thomasdfischer commented 6 years ago

This is a difficult problem to solve in an elegant way.

Joshuad2uiuc commented 6 years ago

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?

narendasan commented 6 years ago

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

Joshuad2uiuc commented 6 years ago

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.

narendasan commented 6 years ago

Perhaps adding support for something like namespaces can help preserve groupings without modifying the config itself