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
Section containing multiple CFG_STR_LIST()s with the same key? #44
Comments
Good question! I have to check that myself first before I can answer. In the meantime, what version of libConfuse are you using? |
Version 2.7, but I tried Git last night and there's no difference, from what I can tell. |
Hi Thomas, On 2015-11-24 11:07, Thomas Adam wrote:
As you guessed, libconfuse does not support that. You need to either create a binding "CM-Return" { or use two lists of strings, i.e. binding-key = {"CM-Return", "CM-Delete", "M-question", "M-period", "M-Return"} (but this one is a bit unreadable if you have long lists) Or perhaps something else? Cheers, |
Hi Peter, Ah, that's a shame. It's interesting how libconfuse lulls you into a false sense of security, since it seems quite happy with the initial structure. :) Would you, or the project, perhaps accept a patch to allow this structure to be supported? If so, I'd ne happy to do that, and to discuss what the semantics internally should look like to support it. I certainly don't like the alternatives, as they're too verbose and don't convey the relationship in the same way that my original example does. |
The thing is that options that are lists of values internally use the same mechanism that sections use when you have multiple sections, i.e. a list of sections for an option instead of a list of values for an option. So, (I assume) you will have to do some major restructuring to support options harboring lists of lists. But an early failure when you cfg_init a bad config template wouldn't be wrong, I suppose. (I'm not in a position to accept or reject anything in this repo, I'm just a random user) |
I don't consider that a problem, and having looked into this, I don't think it's too much work at all. The only concern I have is that it might be seen as a short cut to not using sections. I'll put together a set of patches and see what happens next. If anyone has any thoughts or things they'd like to see from this in the meantime, feel free to speak up, otherwise watch this space! |
@ThomasAdam Looking forward to your proposal! 👍 |
@ThomasAdam consider that cfg_getopt (and other functions too) has to work for looking up the option, so I do not think it is going to be as simple as allowing several option instances with the same name. But maybe you see something that I do not... |
@peda-r - yup, this wasn't going to be trivial, but it doesn't mean it can't be done. We'll see. |
Yep, good luck! Meanwhile, I cooked up #45 so that you get an early error instead of a false hope... |
I see this is a quite old and still open issue with no pull requests, so I am not sure what happened here, but I just wanted to chime in with some thoughts.
In general, I don't think this is much of an issue regarding the library itself, but rather an issue of unfortunate/inefficient design of the way @ThomasAdam wants his data represented in the config file. |
Hi all,
I'm trying to use a section which contains multiple string lists with the same key. Hopefully the following will illustrate how I'm trying to achieve that:
Certainly, if I then do something like this from within my program:
I see:
Which suggests libconfuse is happy, yet when I do something like this:
It prints the value of
1
when I expect to see5
.Am I doing something wrong, or does libconfuse simply not support this type of structure, and is flattening down all of the
key =
lines into one?Any help, greatly appreciated!
The text was updated successfully, but these errors were encountered: