| 299 | } |
| 300 | |
| 301 | bool cmDocumentation::CheckOptions(int argc, char const* const* argv, |
| 302 | char const* exitOpt) |
| 303 | { |
| 304 | // Providing zero arguments gives usage information. |
| 305 | if (argc == 1) { |
| 306 | RequestedHelpItem help; |
| 307 | help.HelpType = cmDocumentation::Usage; |
| 308 | this->RequestedHelpItems.push_back(std::move(help)); |
| 309 | return true; |
| 310 | } |
| 311 | |
| 312 | auto get_opt_argument = [=](int const nextIdx, std::string& target) -> bool { |
| 313 | if ((nextIdx < argc) && !isOption(argv[nextIdx])) { |
| 314 | target = argv[nextIdx]; |
| 315 | return true; |
| 316 | } |
| 317 | return false; |
| 318 | }; |
| 319 | |
| 320 | // Search for supported help options. |
| 321 | |
| 322 | bool result = false; |
| 323 | for (int i = 1; i < argc; ++i) { |
| 324 | if (exitOpt && strcmp(argv[i], exitOpt) == 0) { |
| 325 | return result; |
| 326 | } |
| 327 | RequestedHelpItem help; |
| 328 | // Check if this is a supported help option. |
| 329 | if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0) || |
| 330 | (strcmp(argv[i], "/?") == 0) || (strcmp(argv[i], "-usage") == 0) || |
| 331 | (strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-H") == 0)) { |
| 332 | help.HelpType = cmDocumentation::Help; |
| 333 | i += int(get_opt_argument(i + 1, help.Argument)); |
| 334 | // special case for arbitrary keyword help |
| 335 | if (!help.Argument.empty()) { |
| 336 | help.HelpType = cmDocumentation::OneArbitrary; |
| 337 | i += int(get_opt_argument(i + 1, help.Filename)); |
| 338 | } |
| 339 | } else if (strcmp(argv[i], "--help-properties") == 0) { |
| 340 | help.HelpType = cmDocumentation::OneManual; |
| 341 | help.Argument = "cmake-properties.7"; |
| 342 | i += int(get_opt_argument(i + 1, help.Filename)); |
| 343 | this->WarnFormFromFilename(help, result); |
| 344 | } else if (strcmp(argv[i], "--help-policies") == 0) { |
| 345 | help.HelpType = cmDocumentation::OneManual; |
| 346 | help.Argument = "cmake-policies.7"; |
| 347 | i += int(get_opt_argument(i + 1, help.Filename)); |
| 348 | this->WarnFormFromFilename(help, result); |
| 349 | } else if (strcmp(argv[i], "--help-variables") == 0) { |
| 350 | help.HelpType = cmDocumentation::OneManual; |
| 351 | help.Argument = "cmake-variables.7"; |
| 352 | i += int(get_opt_argument(i + 1, help.Filename)); |
| 353 | this->WarnFormFromFilename(help, result); |
| 354 | } else if (strcmp(argv[i], "--help-modules") == 0) { |
| 355 | help.HelpType = cmDocumentation::OneManual; |
| 356 | help.Argument = "cmake-modules.7"; |
| 357 | i += int(get_opt_argument(i + 1, help.Filename)); |
| 358 | this->WarnFormFromFilename(help, result); |