I'm looking for some library with support for strict set of options (so non-existent options couldn't be set in config file) and possibility to also parse command line to override options from config file. Any ideas?
-
What have you found yourself, e.g. with Google or similar?Some programmer dude– Some programmer dude2012-04-13 14:19:58 +00:00Commented Apr 13, 2012 at 14:19
-
I've found tonns of libraries, but none of them supports command line argument overriding. In other case I wouldn't ask.Daniel– Daniel2012-04-13 14:21:53 +00:00Commented Apr 13, 2012 at 14:21
-
What is problem to use two libraries?Jack– Jack2012-04-13 17:04:15 +00:00Commented Apr 13, 2012 at 17:04
-
combining results also more dependenciesDaniel– Daniel2012-04-15 19:52:23 +00:00Commented Apr 15, 2012 at 19:52
Add a comment
|
2 Answers
For command line, there is getopt or plentiful of code, some with more, some with less strange APIs, some in the form of open-codedness like getopt, others in table form with or without callback ability. As for config file, there is (lib)augeas if you need support for almost arbitrary formats.
1 Comment
Daniel
I need library able to parse both: config files and command line. Not just config files. There are plenty of such libraries.
Assuming you can use LGPL stuff in your project, there's http://www.hyperrealm.com/libconfig/, which appears, according to the docs, to have support in the API for setting values after a file has been parsed.
4 Comments
Daniel
I know that and libconfuse has it too, but I don't want to do that manually. IMHO thats a really common task so there should be some ready solutions.
tbert
You don't want to have to take argv and place it into a library's data manually?
Daniel
No, I don't. Also libconfig doesn't have strict set of options.
Daniel
What infinite number? What drugs? Are you nuts? Thats what I need, but its for C++: boost.org/doc/libs/1_49_0/doc/html/program_options.html It has support for both: config file and command line options.