------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
| 291 | //------------------------------------------------------------------------------------ |
| 292 | //------------------------------------------------------------------------------------ |
| 293 | int GlobalData::ProcessUserInput(int argc, char **argv) |
| 294 | { |
| 295 | try { |
| 296 | string PrgmDesc, cmdlineUsage, cmdlineErrors, cmdlineExtras; |
| 297 | vector<string> cmdlineUnrec; |
| 298 | ostringstream oss; |
| 299 | |
| 300 | // build the command line |
| 301 | opts.DefineUsageString(PrgmName + " [options]"); |
| 302 | PrgmDesc = BuildCommandLine(); |
| 303 | LOG(INFO) << Title; |
| 304 | |
| 305 | // let CommandLine parse options; write all errors, etc to the passed strings |
| 306 | int iret = opts.ProcessCommandLine(argc, argv, PrgmDesc, |
| 307 | cmdlineUsage, cmdlineErrors, cmdlineUnrec); |
| 308 | |
| 309 | // handle return values |
| 310 | if(iret == -2) return iret; // bad alloc |
| 311 | if(iret == -3) return iret; // invalid command line |
| 312 | |
| 313 | // help: print syntax page and quit |
| 314 | if(opts.hasHelp() || trophelp) { |
| 315 | LOG(INFO) << cmdlineUsage; |
| 316 | if(trophelp) |
| 317 | LOG(INFO) << "\n Valid trop model names (cf. gnsstk/core/lib/GNSSCore):\n" |
| 318 | << " GCAT - GPS Code Analysis Tool" << endl |
| 319 | << " GG - Goad and Goodman (1974)" << endl |
| 320 | << " GGHeight - Goad and Goodman with height" << endl |
| 321 | << " Global - the Global (GMF) model" << endl |
| 322 | << " MOPS - RTCA Minimum Operational Performance Standards" << endl |
| 323 | << " NB - New Brunswick" << endl |
| 324 | << " Neill - Neill (Neill 1996)" << endl |
| 325 | << " Saas - Saastamoinen" << endl |
| 326 | << " Simple - a simple Black model" << endl |
| 327 | << " Zero - all zeros"; |
| 328 | |
| 329 | return 1; |
| 330 | } |
| 331 | |
| 332 | // extra parsing (perhaps add to cmdlineErrors, cmdlineExtras) |
| 333 | iret = ExtraProcessing(cmdlineErrors, cmdlineExtras); |
| 334 | if(iret) return iret; |
| 335 | |
| 336 | // output warning / error messages |
| 337 | if(cmdlineUnrec.size() > 0) { |
| 338 | oss << "Warning - unrecognized arguments:"; |
| 339 | for(size_t i=0; i<cmdlineUnrec.size(); i++) |
| 340 | oss << " >" << cmdlineUnrec[i] << "<"; |
| 341 | LOG(WARNING) << oss.str(); |
| 342 | } |
| 343 | |
| 344 | // fatal errors |
| 345 | if(!cmdlineErrors.empty()) { |
| 346 | StringUtils::stripTrailing(cmdlineErrors,'\n'); |
| 347 | StringUtils::replaceAll(cmdlineErrors,"\n","\n "); |
| 348 | LOG(ERROR) << "Errors found on command line:\n " << cmdlineErrors |
| 349 | << "\nEnd of command line errors."; |
| 350 | return -3; |
no test coverage detected