Very simple example:
#include <string>
#include <boost/program_options.hpp>
namespace po = boost::program_options;
int main(int argc, char* argv[])
{
po::options_description recipients("Recipient(s)");
recipients.add_options()
("csv", po::value<std::string>(), "" )
("csv_name", po::value<unsigned>(), "" )
;
po::options_description cmdline_options;
cmdline_options.add(recipients);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(cmdline_options).run(), vm);
po::notify(vm);
return 0;
}
And some tests:
>Test --csv test
in option 'csv_name': invalid option value
>Test --csv_name test
in option 'csv_name': invalid option value
>Test --csv_name 0
>Test --csv text
in option 'csv_name': invalid option value
>Test --csv 0
>Test --csv_name 0
>Test --csv_name 0 --csv text
multiple occurrences
Looks like that boost::program_option threats parameter "csv" as "csv_name".
Is it a feature or bug?