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

Preserving comments #85

Open
Trojaner opened this issue Feb 7, 2021 · 2 comments
Open

Preserving comments #85

Trojaner opened this issue Feb 7, 2021 · 2 comments

Comments

@Trojaner
Copy link

Trojaner commented Feb 7, 2021

Is it possible to update an existing yaml file while preserving comments at the same time?

We currently need this for OpenMod (OpenMod is a free and open source plugin framework). Sometimes we add new options to the config yamls. These need to be merged to the current user configs but we would like to preserve comments. Currently we use YamlDotNet which can't do this and the authors of it don't appear to be interested into adding this either.

Example use case

  1. User installs OpenMod and the following yaml gets created:
rcon:
   # Some long comment that describe what bind does and why it is set like that
   bind: 0.0.0.0
   enabled: true
  1. An OpenMod update adds a new "rcon:port" option with 1554 as default value
  2. The yaml file gets updated while preserving comments:
rcon:
   # Some long comment that describe what bind does and why it is set like that
   bind: 0.0.0.0
   port: 1554
   enabled: true
@xoofx
Copy link
Owner

xoofx commented Feb 8, 2021

Is it possible to update an existing yaml file while preserving comments at the same time?

Probably not out of the box and likely only by using low level model

Currently we use YamlDotNet which can't do this and the authors of it don't appear to be interested into adding this either.

I'm not against the feature but if you want it, you will have to contribute to it, PR welcome

@IncPlusPlus
Copy link

@Trojaner Did you find a solution for this? I'm looking for the same thing.

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

No branches or pull requests

3 participants