Before you say OVERKILL, I don't care.
How can I make Boost.program_options handle the required cat
option -
?
I have
// visible
po::options_description options("Options");
options.add_options()("-u", po::value<bool>(), "Write bytes from the input file to the standard output without delay as each is read.");
po::positional_options_description file_options;
file_options.add("file", -1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(options).positional(file_options).run(), vm);
po::notify(vm);
bool immediate = false;
if(vm.count("-u"))
immediate = true;
if(vm.count("file"))
support::print(vm["file"].as<vector<string>>());
which throws an exception when I run cat - - -
:
unrecognised option '-'
I want it to see -
as a positional argument, and I need it in the correct order in the full file list. How could I achieve this?
UPDATE
I have a half fix. I needed
po::options_description options("Options");
options.add_options()("-u", po::value<bool>(), "Write bytes from the input file to the standard output without delay as each is read.")
("file", po::value< vector<string> >(), "input file");
po::positional_options_description file_options;
file_options.add("file", -1);
Problem is, I seem to only get 2 of the three -
when I output the arguments:
if(vm.count("file"))
support::print(vm["file"].as<vector<string>>());
where support::print nicely handles the vector and stuff.