| 31 | } |
| 32 | |
| 33 | static void write_table_entry(std::ostringstream & ss, const common_arg & opt) { |
| 34 | ss << "| `"; |
| 35 | // args |
| 36 | auto all_args = opt.get_args(); |
| 37 | for (const auto & arg : all_args) { |
| 38 | if (arg == all_args.front()) { |
| 39 | ss << arg; |
| 40 | if (all_args.size() > 1) ss << ", "; |
| 41 | } else { |
| 42 | ss << arg << (arg != all_args.back() ? ", " : ""); |
| 43 | } |
| 44 | } |
| 45 | // value hint |
| 46 | if (opt.value_hint) { |
| 47 | std::string md_value_hint(opt.value_hint); |
| 48 | string_replace_all(md_value_hint, "|", "\\|"); |
| 49 | ss << " " << md_value_hint; |
| 50 | } |
| 51 | if (opt.value_hint_2) { |
| 52 | std::string md_value_hint_2(opt.value_hint_2); |
| 53 | string_replace_all(md_value_hint_2, "|", "\\|"); |
| 54 | ss << " " << md_value_hint_2; |
| 55 | } |
| 56 | // help text |
| 57 | std::string md_help(opt.help); |
| 58 | md_help = string_strip(md_help); |
| 59 | string_replace_all(md_help, "\n", "<br/>"); |
| 60 | string_replace_all(md_help, "|", "\\|"); |
| 61 | ss << "` | " << md_help << " |\n"; |
| 62 | } |
| 63 | |
| 64 | static void write_table(std::ostringstream & ss, std::vector<common_arg *> & opts) { |
| 65 | write_table_header(ss); |
no test coverage detected