Snap! Websites
An Open Source CMS System in C++
The advanced getopt library to handle your command line tools seemlessly.
The library offers an advanced way to parse command line arguments, an environment variable, and configuration files in a seamless manner. The advgetopt::getopt class is what is used everywhere for that purpose.
The class can be used in a very restrictive mode, meaning that all the parameters must clearly be defined by the application. It can also be used in a dynamic way where the parameters are dynamically added to the list of available options.
The library supports multiple levels in your options. The simplest is to use a scope operator like so:
The labels in a .ini format (i.e. [name]
defines sections) are viewed as a first level. That name automatically get prepended to the parameters appearing under them. Additional levels can be added by using the scope operator, again.
Support for other formats may be added later. For example, we could read XML and JSON files. Right now, we are focused on Unix configuration files and pretty much never even need two levels.
The library is capable of writing your configuration back to file. It will know when a value was modified and only the modified values get saved to the read/write configuration file(s). (Either the user file or the system file under the \<proc>.d/...
sub-path.)
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.
Snap! Websites
An Open Source CMS System in C++