formats the list of pairs in two columns
| 26 | // formats the list of pairs in two columns |
| 27 | // |
| 28 | std::string table(const std::vector<std::pair<std::string, std::string>>& v, |
| 29 | std::size_t indent, std::size_t spacing) |
| 30 | { |
| 31 | std::size_t longest = 0; |
| 32 | |
| 33 | for (auto&& p : v) |
| 34 | longest = std::max(longest, p.first.size()); |
| 35 | |
| 36 | std::string s; |
| 37 | |
| 38 | for (auto&& p : v) { |
| 39 | if (!s.empty()) |
| 40 | s += "\n"; |
| 41 | |
| 42 | s += std::string(indent, ' ') + pad_right(p.first, longest) + " " + |
| 43 | std::string(spacing, ' ') + p.second; |
| 44 | } |
| 45 | |
| 46 | return s; |
| 47 | } |
| 48 | |
| 49 | CommandLine::CommandLine() : m_command(nullptr) |
| 50 | { |