TODO: normalize/simplify/native all path parameters TODO: error out on all missing given files/paths
| 313 | // TODO: normalize/simplify/native all path parameters |
| 314 | // TODO: error out on all missing given files/paths |
| 315 | CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const argv[]) |
| 316 | { |
| 317 | mSettings.exename = Path::getCurrentExecutablePath(argv[0]); |
| 318 | |
| 319 | bool xmlOptionProvided = false; |
| 320 | bool outputFormatOptionProvided = false; |
| 321 | |
| 322 | // default to --check-level=normal from CLI for now |
| 323 | mSettings.setCheckLevel(Settings::CheckLevel::normal); |
| 324 | |
| 325 | // read --debug-lookup early so the option is available for the cppcheck.cfg loading |
| 326 | for (int i = 1; i < argc; i++) { |
| 327 | // Show debug warnings for lookup for configuration files |
| 328 | if (std::strcmp(argv[i], "--debug-lookup") == 0) |
| 329 | mSettings.debuglookup = true; |
| 330 | |
| 331 | else if (std::strncmp(argv[i], "--debug-lookup=", 15) == 0) { |
| 332 | const std::string lookup = argv[i] + 15; |
| 333 | if (lookup == "all") |
| 334 | mSettings.debuglookup = true; |
| 335 | else if (lookup == "addon") |
| 336 | mSettings.debuglookupAddon = true; |
| 337 | else if (lookup == "config") |
| 338 | mSettings.debuglookupConfig = true; |
| 339 | else if (lookup == "library") |
| 340 | mSettings.debuglookupLibrary = true; |
| 341 | else if (lookup == "platform") |
| 342 | mSettings.debuglookupPlatform = true; |
| 343 | else |
| 344 | { |
| 345 | mLogger.printError("unknown lookup '" + lookup + "'"); |
| 346 | return Result::Fail; |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | if (!loadCppcheckCfg()) |
| 352 | return Result::Fail; |
| 353 | |
| 354 | if (argc <= 1) { |
| 355 | printHelp(); |
| 356 | return Result::Exit; |
| 357 | } |
| 358 | |
| 359 | // check for exclusive options |
| 360 | for (int i = 1; i < argc; i++) { |
| 361 | // documentation.. |
| 362 | if (std::strcmp(argv[i], "--doc") == 0) { |
| 363 | std::ostringstream doc; |
| 364 | // Get documentation.. |
| 365 | for (const Check * const c : CheckInstances::get()) { |
| 366 | const std::string& name(c->name()); |
| 367 | const std::string info(c->classInfo()); |
| 368 | if (!name.empty() && !info.empty()) |
| 369 | doc << "## " << name << " ##\n" |
| 370 | << info << "\n"; |
| 371 | } |
| 372 |
nothing calls this directly
no test coverage detected