-
Notifications
You must be signed in to change notification settings - Fork 308
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
Option to make headings optional in ini files #43
Comments
This is only true for option groups, but not for commands. I'm not really seeing any issue with nicely separating your options in the ini file in the structure of option groups. If you don't like the default option group name, then you can use flags.NewNamedParser and add an option group to it manually, with another name. |
Why would I have the same named command in two groups? Heck, I don't even really see the need for groups, at least in my case. Yes I can add the header because I know about it, but my users will not. I'm trying to lower the bar of complexity for them. Most programs that take ini/conf files do not contain or use headers. The only popular example I can think of that does is php.ini, and the headers are optional. |
I guess you misunderstood. Sections in ini files can be used to specify the options of a command. Multiple commands can have the same options (and a command can have the same flag as the global flags), so in that case you will need to use a section in the ini file. The support for ini files is really meant/written as a convenience, and not as an integral part of go-flags. If you need something that works differently, then you can use your own config parser to fill in the struct fields. Finally, with regard to not specifying a group header, I guess I'm fine with having options without a section in the ini file, and have those being mapped to any group at the toplevel of the parser. It's easy to implement. |
Oh, ok. Yeah I did misunderstand that. An option like that would be good, thank you for considering it. |
This should be fixed now. Options specified in the global section (i.e. no section specified) will be matched against all toplevel groups, in order in which those groups are defined. Feel free to reopen the issue if you still encounter problems. |
Command line options are unique, so they cannot reoccur across sections. Thus it would make sense to make headings in ini files optional. At least, have an option to specify the group that belongs to the headless section at the top of the ini file.
The text was updated successfully, but these errors were encountered: