cxxopts icon indicating copy to clipboard operation
cxxopts copied to clipboard

Getting full arguments value set as string including default & implicit

Open m4saka opened this issue 7 years ago • 1 comments

Hi.

My application will have a lot of parameters, so I'd like to get the full list of arguments from cxxopts and save the set as a text file.

Is it possible to iterate all arguments with specified values including default and implicit ones with cxxopts?

ParseResult::arguments() enables to get an argument list as std::vector<KeyValue>, but it doesn't contain default values. And ParseResult has unordered_map-like overloads but it cannot be used for iteration.

auto result = options.parse(argc, argv);

// You can't do this
for (auto && argument : result)
{
    std::cout << argument.first << "=" << argument.second.as<std::string>() << std::endl;
}

m4saka avatar Aug 29 '18 20:08 m4saka

I can work on adding something like that to the interface.

jarro2783 avatar Aug 29 '18 22:08 jarro2783