Red Hat Bugzilla – Bug 56860
ENH: parse a file as a command line
Last modified: 2008-05-01 11:38:01 EDT
for our project, we wanted to have a flexable and easy to use config file
parser. using tools we already like would be a plus, so, popt came to mind.
popt has the ability to read from a poptrc file for doing the aliases - but
this is not what we wanted. our going is a standard
type config file. so, we wrote a function to convert this type of file to
a string which allowed us to slam the result through poptParseArgvString()
and then via the poptGetNextOpt() methods to fully read the file. now, we
just set up the popt array and management is much easier. in fact, we can
also use the same array for reading command line and config file options.
so, basically, the first step is to write a config-file-to-string function
- which is attached to this bug (along with unit tests).
our code did many more complicated things, some of which i'll contribute
back to popt, but this function is the first step. please examine,
comment, and perhaps we need to change the calling conventions and such.
two attachments: a cvs diff and a tgz of new files.
Created attachment 39004 [details]
diffs to add poptConfigFileToString function
Created attachment 39005 [details]
unit tests for poptConfigFileToString function
OK, your patch is going in on my next checkin,
should be in popt-1.7-0.51.
Be forewarned, I'm not sure how useful parsing
a config file into a string of options is, so
expect the code to change, and possibly be reverted.