Getting configuration options

Take a look at some of the console programs, such as cp in Linux. They all have a fancy help, their input parameters do not depend on any position, and have a human readable syntax, for example:

$ cp --help 

Usage: cp [OPTION]... [-T] SOURCE DEST 
  -a, --archive           same as -dR --preserve=all 
  -b                      like --backup but does not accept an argument

You can implement the same functionality for your program in 10 minutes. And all you need is the Boost.ProgramOptions library.

Getting ready

Basic knowledge of C++ is all you need for this recipe. Remember that this library is not a header-only, so your program will need to link against the libboost_program_options library.

How to do it...

Let's start with a simple program that accepts ...

Get Boost C++ Application Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.