diff --git a/src/osg/ArgumentParser.cpp b/src/osg/ArgumentParser.cpp index 0ec0305a4..8b2837c7f 100644 --- a/src/osg/ArgumentParser.cpp +++ b/src/osg/ArgumentParser.cpp @@ -1,6 +1,8 @@ #include #include +#include + using namespace osg; ArgumentParser::ArgumentParser(int* argc,char **argv): @@ -20,7 +22,10 @@ int ArgumentParser::find(const std::string& str) const { for(int pos=1;pos<*_argc;++pos) { - if (str==_argv[pos]) return pos; + if (str==_argv[pos]) + { + return pos; + } } return 0; } @@ -275,9 +280,33 @@ void ArgumentParser::reportError(const std::string& message,ErrorSeverity severi void ArgumentParser::reportRemainingOptionsAsUnrecognized(ErrorSeverity severity) { + std::set options; + if (_usage) + { + // parse the usage options to get all the option that the application can potential handle. + for(ApplicationUsage::UsageMap::const_iterator itr=_usage->getCommandLineOptions().begin(); + itr!=_usage->getCommandLineOptions().end(); + ++itr) + { + const std::string& option = itr->first; + unsigned int prevpos = 0, pos = 0; + while ((pos=option.find(' ',prevpos))!=std::string::npos) + { + if (option[prevpos]=='-') options.insert(std::string(option,prevpos,pos-prevpos)); + prevpos=pos+1; + } + if (option[prevpos]=='-') options.insert(std::string(option,prevpos,std::string::npos)); + } + + } + for(int pos=1;pos