diff --git a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx index de4838af4fa18567aa7b36e21fc7dca196bbdf96..0aa4ada16df66af94bd89bb6c233d780a338357d 100644 --- a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx +++ b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx @@ -109,7 +109,7 @@ CommandLineLauncher::Load() if( this->CheckParametersPrefix() == true ) { - std::cerr<<"ERROR: Parameter keys have to set using \"--\""<<std::endl; + std::cerr<<"ERROR: Parameter keys have to set using \"--\", not \"-\""<<std::endl; return true; } @@ -430,7 +430,7 @@ CommandLineLauncher::LoadParameters() else if (values.size() != 1 && values.size() != 2) { - std::cerr << "ERROR: Invalid number of value: " << paramKey << " , invalid number of values " << values.size() << std::endl; + std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", invalid number of values " << values.size() << std::endl; return INVALIDNUMBEROFVALUE; } } @@ -442,7 +442,19 @@ CommandLineLauncher::LoadParameters() else if (values.size() != 1) { - std::cerr << "ERROR: Invalid number of value:" << paramKey << ", must have 1 value, not " << values.size() << std::endl; + std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", must have 1 value, not " << values.size() << std::endl; + // Try to find a "-" instead of "--"... + itk::OStringStream oss; + for(unsigned int i=0; i<values.size(); i++) + { + if(values[i][0] == '-') + { + oss<<std::string(values[i]).substr(1, std::string(values[i]).size()-1)<<", "; + } + } + if( oss.str().size() >0 ) + std::cerr << "ERROR: If values \""<<oss.str().substr(0, oss.str().size()-2)<<"\" is/are keys, it should be prefix by \"--\"..."<< std::endl; + return INVALIDNUMBEROFVALUE; } @@ -823,8 +835,8 @@ CommandLineLauncher::CheckParametersPrefix() // If the expression contains parameters if( spaceSplittedExp.size() > 2 ) { - // Check if the chain "--" appears at least one time - if( m_Expression.find("--") == std::string::npos) + // Check if the chain "--" appears at least one time when "-" is present + if( m_Expression.find("--") == std::string::npos && m_Expression.find("-") != std::string::npos) { res = true; } diff --git a/Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx b/Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx index 4dedf5155bdbb325802ba8f8f7a8c5990457f4ef..b4f43c08d8f3feb7cebe44d6985a886c8398eaf9 100644 --- a/Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx +++ b/Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx @@ -93,14 +93,24 @@ CommandLineParser::GetPaths( std::vector<std::string> & paths, const std::string for(unsigned int i=0; i<pathAttribut.size(); i++) { // Suppress possible multi space at the beginning of the string - while (pathAttribut[i].size()>0 && pathAttribut[i][0]==' ') + while (pathAttribut[i].size()>1 && pathAttribut[i][0]==' ') { pathAttribut[i].erase(0, 1); } + + // case where the user set -key instead of --key + // Having __key is not not, we've splitted the expression to the + // first "--" + if(pathAttribut[i][0] == '-') + { + std::cerr<<"ERROR: Parameter keys have to set using \"--\", not \"-\""<<std::endl; + return INVALIDMODULEPATH; + } std::string fullPath = itksys::SystemTools::CollapseFullPath(pathAttribut[i].c_str()); + if( !itksys::SystemTools::FileIsDirectory(fullPath.c_str()) ) { - std::cerr<<"module path Inavlid module path"<<std::endl; + std::cerr<<"module path Invalid module path: "<<fullPath<<std::endl; return INVALIDMODULEPATH; } paths.push_back(fullPath);