| 524 | } |
| 525 | |
| 526 | std::vector<Option> parse_defaults(std::string const& doc) { |
| 527 | // This pattern is a delimiter by which we split the options. |
| 528 | // The delimiter is a new line followed by a whitespace(s) followed by one or two hyphens. |
| 529 | static std::regex const re_delimiter{ |
| 530 | "(?:^|\\n)[ \\t]*" // a new line with leading whitespace |
| 531 | "(?=-{1,2})" // [split happens here] (positive lookahead) ... and followed by one or two hyphes |
| 532 | }; |
| 533 | |
| 534 | std::vector<Option> defaults; |
| 535 | for (auto s : parse_section("options:", doc)) { |
| 536 | s.erase(s.begin(), s.begin() + static_cast<std::ptrdiff_t>(s.find(':')) + 1); // get rid of "options:" |
| 537 | |
| 538 | for (const auto& opt : regex_split(s, re_delimiter)) { |
| 539 | if (starts_with(opt, "-")) { |
| 540 | defaults.emplace_back(Option::parse(opt)); |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | return defaults; |
| 546 | } |
| 547 | |
| 548 | static bool isOptionSet(PatternList const& options, std::string const& opt1, std::string const& opt2 = "") { |
| 549 | return std::any_of(options.begin(), options.end(), [&](std::shared_ptr<Pattern const> const& opt) -> bool { |
no test coverage detected