Vladimir Prus 2002 2003 2004 Vladimir Prus Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Facilities to obtain configuration data from command line, config files and other sources Boost.Program_options
Introduction The program_options library allows program developers to obtain program options, i.e. (name,value) pairs from the user, via conventional methods such as command line and config file. Why would you use such a library, and why it's better than parsing your command line by trivial hand-written code? Some of the reasons are: It's easier. The syntax for declaring options is simple, and the library itself is small. Things like conversion of option values to desired type and storing into program variables are handled automatically. Error reporting is better. All problems with command line are reported, while hand-written code can just misparse the input. In addition, the usage message can be automatically generated, to avoid falling out of sync with the real list of options. Options can be read from anywhere. Sooner or later command line will be not enough for your users, and you'd want config files or maybe even environment variables. This can be added without no effort on your part. Now let's see some examples of the library usage in the .