Commit 3c3d2003ca999302f7a14dcbba2af9485510334d
1 parent
1be5f10d
add help for positional parameters
Showing
2 changed files
with
12 additions
and
1 deletions
include/cxxopts.hpp
| ... | ... | @@ -681,11 +681,20 @@ namespace cxxopts |
| 681 | 681 | Options(std::string program, std::string help_string = "") |
| 682 | 682 | : m_program(std::move(program)) |
| 683 | 683 | , m_help_string(toLocalString(std::move(help_string))) |
| 684 | + , m_positional_help("positional parameters") | |
| 684 | 685 | , m_next_positional(m_positional.end()) |
| 685 | 686 | { |
| 686 | 687 | } |
| 687 | 688 | |
| 688 | 689 | inline |
| 690 | + Options& | |
| 691 | + positional_help(const std::string& help_text) | |
| 692 | + { | |
| 693 | + m_positional_help = std::move(help_text); | |
| 694 | + return *this; | |
| 695 | + } | |
| 696 | + | |
| 697 | + inline | |
| 689 | 698 | void |
| 690 | 699 | parse(int& argc, char**& argv); |
| 691 | 700 | |
| ... | ... | @@ -795,6 +804,7 @@ namespace cxxopts |
| 795 | 804 | |
| 796 | 805 | std::string m_program; |
| 797 | 806 | String m_help_string; |
| 807 | + std::string m_positional_help; | |
| 798 | 808 | |
| 799 | 809 | std::map<std::string, std::shared_ptr<OptionDetails>> m_options; |
| 800 | 810 | std::vector<std::string> m_positional; |
| ... | ... | @@ -1369,7 +1379,7 @@ Options::help(const std::vector<std::string>& groups) const |
| 1369 | 1379 | toLocalString(m_program) + " [OPTION...]"; |
| 1370 | 1380 | |
| 1371 | 1381 | if (m_positional.size() > 0) { |
| 1372 | - result += " positional parameters"; | |
| 1382 | + result += " " + toLocalString(m_positional_help); | |
| 1373 | 1383 | } |
| 1374 | 1384 | |
| 1375 | 1385 | result += "\n\n"; | ... | ... |