|laziness, impatience, and hubris|
Configuration file designby castaway (Parson)
|on Jan 04, 2005 at 09:14 UTC||Need Help??|
A script I am writing doesn't have a GUI, or much user interaction (it basically just warns of potential destructive actions, and asks the user to hit a key to continue, or ctrl-c to stop), it does have a configuration file, however. Since this is it's only user-editable interface, I'd like to keep it simple and fairly self-explanatory.
Which is where I've run into some problems, how to design it so I can fit in all the info I'm likely to need, and keep it simple? How do other people design their configuration files?
To the specific problem: currently my configuration file just contains a bunch of "XXX=YYY" lines, where the variable names are fairly self explanatory (to users of this program anyway. The script itself is intended to be a shortcut to installing a complex piece of software, which normally requires the installer to edit/apply a bunch of templates to create the configuration. (For example, some variables appear in multiple configuration files for this software, and need to be the same in order for it to function properly, they're usually paths). Anyfish, one of these configuration files contains a variable FTP_INSTANCES which contains a list of numbers, eg: FTP_INSTANCES="01 02 03 04". For each of the numbers contained in this variable, I need to be able to configure a file with the number in its name (in this case, my script should produce the files ftp01.cfg ftp02.cfg ftp03.cfg ftp04.cfg), each containing different information about the ftp server they are supposed to collect files from. So, how do I represent this information in my scripts configuration file, without getting too complex?
I have a feeling I might need to make it like an .ini file:
I don't find it very pretty though, or intuitive (that the user will need to create as many new ftpXX sections as they need for the values in the ftp_instances variable). Also my config file parser will need to be more complex, since currently I'm just splitting on /=/ and that's it.
There appears to be a ton of configuration modules on CPAN, maybe I'm missing a good one, most seem to concentrate on configurations created by, and read by, programs, I'd like one thats easily writeable by humans, and read by programs (with appropriate errors when malformed). Config::General, for example, writes its 'blocks' as xml-like tagged blocks:
Which is/would be a more typing for the user, and thus more to get wrong..
Any suggestions, clues?
Update:Removed confusing restriction