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

Insert Duplicate Section? #65

Open
theonewolf opened this issue May 2, 2020 · 2 comments
Open

Insert Duplicate Section? #65

theonewolf opened this issue May 2, 2020 · 2 comments

Comments

@theonewolf
Copy link

I am testing support for duplicate sections, and I can not figure out how to add a new section with the same name as an old section. I actually don't think it's exposed in your API currently.

Parsing duplicate sections from files works fine, but adding same named sections does not (using with_section). I recommend adding a new method for instantiating sections, or a boolean on with_section that flags creation of a section--not retrieval / insertion into a pre-existing section.

@zonyitoo very close to having full support for #49! Instead of re-opening it, I figured I'd file another bug report.

@zonyitoo
Copy link
Owner

zonyitoo commented May 3, 2020

Hmm, I didn't add that because with_section was defined for insert or modify the section that is already existed.

Consider using the entry API:

let mut ini = Ini::new();
match ini.entry(Some("KeyDuplicated")) {
    SectionEntry::Vacant(mut vac) => {
    }
    SectionEntry::Occupied(mut occ) => {
        // Append a new section with the same name
        occ.append(...);
    }
}

@theonewolf
Copy link
Author

@zonyitoo thanks for the tip, I'll let you know if it covers my use case and close this out. Yes, with your API and how things work it did feel odd adding in what I described.

I really wish systemd used a standard configuration format vs rolling their own.

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

2 participants