Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write template with values from a loaded config #41

Open
LukasKalbertodt opened this issue Oct 18, 2024 · 0 comments
Open

Write template with values from a loaded config #41

LukasKalbertodt opened this issue Oct 18, 2024 · 0 comments

Comments

@LukasKalbertodt
Copy link
Owner

(This issue replaces #32, #29 and #28 in order to have one place to discuss this general feature)

confique can emit "config templates" which contain the documentation, the default values and various other information. By deriving Serialize for your config, you can also write a loaded config back to file via serde -- without any documentation or other information though! It would be nice to write a template file, but with values coming from a loaded configuration. There are a few different use cases/requirements (random unordered sorts follow):

  • git config set-like workflows that should not overwrite the whole config, but only edit a particular value. (Would you consider modification of config files? #29)
  • Not always serializing the loaded Config, but rather a Partial, so that default values will stay #value = "foo" in the config, and not valid = "foo". (Automatic support for skip_serializing_if on each field #28)
  • Library users should be able to control whether non-set values should be emitted (with #value = "foo" and docs) or not at all.
  • Apps with a config-UI would want to set one value in the Partial-tree probably, and then write that to the config.
  • Users of this library that are not interested in the feature, shouldn't pay in compile times for unused Serialize code

It seems to me that this requires a few things:

  • Probably some dynamic way to index into a configuration. I don't want to generate a whole bunch of code for this use case for every struct field. Have to think about this more.
  • Maybe ability to get a list of layers from the builder? Or should people just not use the builder if they need explicit control over layers?
  • Editing existing config files requires special support like toml-edit.

None of these use cases are promised to land in confique. Especially the "edit existing file" seems very hard to me and I'm not sure if it's worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant