Snap! Websites
An Open Source CMS System in C++
This project is an advanced getopt() class to use with your C++ projects. It handles most everything that GNU-like tools offer as far as command line options go.
The main idea is for you to have as little to do as possible parsing your command line arguments and configuration files. The library expects a table of available options with a short and long version of the options, and whether they accept arguments (i.e. -f <filename>).
In your C++ program you can then just check whether a parameter is defined or not with the is_defined() function and get the value as a string, an integer, etc. as required by your tool. Data verification is done automatically using validators. Since you can create your own validators, pretty much any data type is supported.
The library version 2.x has the following features:
In the future we may add support for JSON, XML, and some other formats where configuration data could be saved. Such support may be limited but it would still be useful if you prefer to use such rather than the default Unix like syntax for your configuration files.
The source is available on github in our project git.
On Ubuntu, you may want to install it from our Snap! C++ Launchpad PPA. In that case, add the repository this way:
sudo add-apt-repository ppa:snapcpp/ppa sudo apt-get update
Then install one of the library packages with the install command:
sudo apt-get install libadvgetopt sudo apt-get install libadvgetopt-dev sudo apt-get install libadvgetopt-doc
List of currently available Snap! C++ packages.
You got a problem with the library? An idea to improve it? Please post a ticket in the Support area of Github.
Version 2.x requires the following to compile and use the library:
We use cmake to build everything. If you have Ubuntu, using the PPA (see Download above) will probably be much easier for you. We include a development package so you can directly compile and link against this library.
The libadvgetopt-doc package includes all the documentation on how to use the library. You can also find a copy of the advgetopt reference on this website.
The different snapwebsites tools (under snapwebsites/<project-name>/src) will give you extensive examples on how the library gets used.
The library comes with a unit test which attempts to keep the coverage as close as possible to 100%. The test results can be found on lcov.snapwebsites.org/advgetopt.
This library was originally developed for wpkg.
Snap! Websites
An Open Source CMS System in C++