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

How to set/change comment for existing group? #13

Open
DrTiBiBo opened this issue Sep 3, 2024 · 1 comment
Open

How to set/change comment for existing group? #13

DrTiBiBo opened this issue Sep 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@DrTiBiBo
Copy link

DrTiBiBo commented Sep 3, 2024

Hello,

I'm trying to set/change comment for existing group, but no success.

Existing nginx config has 4 server blocks and I need to change some content inside and I would like to add comments for each server block.
After this code the filed comment is empty for the first block:

var nginx = NginxConfig.LoadFrom(nginxConfigPath);
    nginx.AddOrUpdate("server[0]", "", true, "Some comment for the first server block");

Could you please tell me if it possible and how it is possible?

Thanks in advance

@jxnkwlp jxnkwlp added the bug Something isn't working label Sep 4, 2024
@jxnkwlp
Copy link
Owner

jxnkwlp commented Sep 4, 2024

It looks like a bug when change exist group block comment.

But, if remove and then add it again, can temporary fix this issues.

I will fix it as soon as possible.
Thanks.

string source = NginxConfig.Create()
	.AddOrUpdate("server[0]", "", true, "Comment1")
	.AddOrUpdate("server[1]", "", true, "Comment2") 
	// save file
	.ToString();

source.Dump();

NginxConfig.Load(source)
    // .Remove("server[0]")
	.AddOrUpdate("server[0]", "", true, "Comment1 changed")
	.AddOrUpdate("server[1]", "", true, "Comment2 changed")
	.ToString()
	.Dump();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants