MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / help_one_group

Method help_one_group

Source/Utils/cxxopts.hpp:2538–2612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2536}
2537
2538inline
2539String
2540Options::help_one_group(const std::string& g) const
2541{
2542 using OptionHelp = std::vector<std::pair<String, String>>;
2543
2544 auto group = m_help.find(g);
2545 if (group == m_help.end())
2546 {
2547 return "";
2548 }
2549
2550 OptionHelp format;
2551
2552 size_t longest = 0;
2553
2554 String result;
2555
2556 if (!g.empty())
2557 {
2558 result += toLocalString(" " + g + " options:\n");
2559 }
2560
2561 for (const auto& o : group->second.options)
2562 {
2563 if (m_positional_set.find(o.l) != m_positional_set.end() &&
2564 !m_show_positional)
2565 {
2566 continue;
2567 }
2568
2569 auto s = format_option(o);
2570 longest = (std::max)(longest, stringLength(s));
2571 format.push_back(std::make_pair(s, String()));
2572 }
2573 longest = (std::min)(longest, OPTION_LONGEST);
2574
2575 //widest allowed description -- min 10 chars for helptext/line
2576 size_t allowed = 10;
2577 if (m_width > allowed + longest + OPTION_DESC_GAP)
2578 {
2579 allowed = m_width - longest - OPTION_DESC_GAP;
2580 }
2581
2582 auto fiter = format.begin();
2583 for (const auto& o : group->second.options)
2584 {
2585 if (m_positional_set.find(o.l) != m_positional_set.end() &&
2586 !m_show_positional)
2587 {
2588 continue;
2589 }
2590
2591 auto d = format_description(o, longest + OPTION_DESC_GAP, allowed, m_tab_expansion);
2592
2593 result += fiter->first;
2594 if (stringLength(fiter->first) > longest)
2595 {

Callers

nothing calls this directly

Calls 9

toLocalStringFunction · 0.85
format_optionFunction · 0.85
stringLengthFunction · 0.85
format_descriptionFunction · 0.85
findMethod · 0.80
endMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected