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

Consider preserving comments when re-writing values? #19

Open
erwin opened this issue Oct 8, 2021 · 0 comments
Open

Consider preserving comments when re-writing values? #19

erwin opened this issue Oct 8, 2021 · 0 comments

Comments

@erwin
Copy link

erwin commented Oct 8, 2021

I've been searching quite a bit for an easy to use C config file library that supports preserving comments.

If I have the following in my INI file.

[section:foo]
alpha=True ; comment preserved
beta=True  ; until the value changes

And then use minIni to change the value of beta:

  ini_puts("section:foo", "beta", "False", inifile2);

The comment on beta will be lost...

[section:foo]
alpha=True ; comment preserved
beta=False

Not every config value change will invalidate the meaning of the associated comment, and since minIni doesn't write comments, only the user should be writing comments... Would be very frustrating for the end user to loose some comments they thought were important when we rewrite config changes.

As a workaround, one idea that comes to mind is putting a prefix or a suffix or both on the subset of key values that your program will be re-writing, so that these values jump out to the user as odd in the config file and are less surprised when comments there disappear. The downside of this approach would be as your software evolves and a value goes from user only to program re-written with the same name, so not an ideal workaround.

Something like:

[section:foo]
normal_key = value ; description of normal key
$app_configured = other value ; maybe less surprising if this comment gets erased?
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