You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker for an issue that matches the one I want to file, without success.
Problem Description
It would be fantastic if Viper would support adding comments to configuration files and individual fields.
Currently my application writes YAML config file the following header:
# Configuration file for ${APPLICATION NAME}.# For an explanation of the fields, refer to {application}-example.yaml## NOTE: this file will be overwritten by ${APPLICATION NAME}'s web-based configuration system.## This file was written on ${TIMESTAMP} by ${APPLICATION NAME}-${VERSION}
Having Viper produce such a header (on file types where comments are supported, of course) would be fantastic. Also in this particular header you can see that there's an example file with documentation in the comments. Having such documention comments produced by Viper would be amazing, as then the file itself could be written like:
# ${APPLICATION} listens to incoming connections from workers on this address.listen: ':8080'
Proposed Solution
An API like this could work:
v.SetDocumentation("Configuration file for ${APPLICATION NAME}....")
v.SetDefault("listen", ":8080")
v.SetFieldDocumentation("listen", ${APPLICATION} listenstoincomingconnectionsfromworkersonthisaddress.")
Alternatives Considered
The obvious alternative is to simply not have support for comments, as we have now.
Additional Information
An open question would be what to do with existing comments in the file. Would these be remembered when rewriting? Or would rewriting the config file always write the set-in-the-code documentation strings? I think the latter would be the easiest to implement, and it also allows updating that documentation in the config file when the application is updated.
The text was updated successfully, but these errors were encountered:
Preflight Checklist
Problem Description
It would be fantastic if Viper would support adding comments to configuration files and individual fields.
Currently my application writes YAML config file the following header:
Having Viper produce such a header (on file types where comments are supported, of course) would be fantastic. Also in this particular header you can see that there's an example file with documentation in the comments. Having such documention comments produced by Viper would be amazing, as then the file itself could be written like:
Proposed Solution
An API like this could work:
Alternatives Considered
The obvious alternative is to simply not have support for comments, as we have now.
Additional Information
An open question would be what to do with existing comments in the file. Would these be remembered when rewriting? Or would rewriting the config file always write the set-in-the-code documentation strings? I think the latter would be the easiest to implement, and it also allows updating that documentation in the config file when the application is updated.
The text was updated successfully, but these errors were encountered: