I'm attempting to get all of the input given in the commandline after a certain flag, it seems that boost delimits after a space, and I'm trying to get more than one piece of data for the given command.
For example given the command ./Program -n Name -t Type -a key=value key=value key=value
Name, and Type will be stored correctly, but the series of key=values will not, only the first one will be stored, while I want to store all of them. Instead of having a string result of just key=value
I want key=value key=value key=value
stored in that string.
Is there a known way of allowing boost to store a string that is not delimited by a space. I cannot post my exact code, but it looks very similar to this example:
#include <boost/program_options.hpp>
#include <iostream>
using namespace boost::program_options;
void on_age(int age)
{
std::cout << "On age: " << age << '\n';
}
int main(int argc, const char *argv[])
{
try
{
options_description desc{"Options"};
desc.add_options()
("help,h", "Help screen")
("name,n", value<string>(), "name")
("type,t", value<string>(), "type")
("args,a", value<string>(), "args");
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);
if (vm.count("help"))
std::cout << desc << '\n';
if (vm.count("name"))
std::cout << "Name: " << vm["name"].as<string>() << '\n';
if (vm.count("type"))
std::cout << "Type: " << vm["type"].as<string>() << '\n';
if (vm.count("args"))
std::cout << "Args: " << vm["args"].as<string>() << '\n';
}
catch (const error &ex)
{
std::cerr << ex.what() << '\n';
}
}
What modifications can I make to my code that will allow the program options to store until either the next flag or the end of the input. This will generally be the last flag called as well.