I have further refined the command line parsing code in the assimp ReaderWriter so it uses a vsg::CommandLine method:
template<typename T>
bool readAndAssign(const std::string& match, Options* options)
The code to parse the command line arguments now looks like:
bool assimp::readOptions(vsg::Options& options, vsg::CommandLine& arguments) const
{
bool result = arguments.readAndAssign<void>(assimp::generate_smooth_normals, &options);
result = arguments.readAndAssign<void>(assimp::generate_sharp_normals, &options) | result;
result = arguments.readAndAssign<float>(assimp::crease_angle, &options) | result;
return result;
}
Note the type passed in for the first two readAndAssign() calls above use void type, which tells the readAndAsssign method just to look for a --match without a parameter this means we can now simple write on the command line:
vsgviewer wuson.dxf --generate_sharp_normals
The readAnAssign method also adds the "--" prefix automatically, so there is no need to add this yourself, instead you just pass in the "string" that you want to match and then assign the vsg::Options. For the case of a void type match a options->setValue(match, true); is used.
I was originally thinking about automating more of the code for reading and reporting the features, but now feel that would add more complexity and make the code less easy to follow, so while what we now have is a bit verbose it's not a huge amount of code, especially now we have the CommandLine::readAndAssign(..) convenience method,