Commit 3c3d2003ca999302f7a14dcbba2af9485510334d

Authored by Jarryd Beck
1 parent 1be5f10d

add help for positional parameters

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&lt;std::string&gt;&amp; 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";
... ...
src/example.cpp
... ... @@ -31,6 +31,7 @@ int main(int argc, char* argv[])
31 31 try
32 32 {
33 33 cxxopts::Options options(argv[0], " - example command line options");
  34 + options.positional_help("[optional args]");
34 35  
35 36 bool apple = false;
36 37  
... ...