Commit 2abdd4af4db0c794eb7eedce65b6c330052bdf0a
Committed by
GitHub
1 parent
01798ee7
Add option to display usage (#355)
Make the usage displaying optional
Showing
1 changed file
with
7 additions
and
4 deletions
include/cxxopts.hpp
| ... | ... | @@ -1893,7 +1893,7 @@ class Options |
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | std::string |
| 1896 | - help(const std::vector<std::string>& groups = {}) const; | |
| 1896 | + help(const std::vector<std::string>& groups = {}, bool print_usage=true) const; | |
| 1897 | 1897 | |
| 1898 | 1898 | std::vector<std::string> |
| 1899 | 1899 | groups() const; |
| ... | ... | @@ -2725,10 +2725,13 @@ Options::generate_all_groups_help(String& result) const |
| 2725 | 2725 | |
| 2726 | 2726 | inline |
| 2727 | 2727 | std::string |
| 2728 | -Options::help(const std::vector<std::string>& help_groups) const | |
| 2728 | +Options::help(const std::vector<std::string>& help_groups, bool print_usage) const | |
| 2729 | 2729 | { |
| 2730 | - String result = m_help_string + "\nUsage:\n " + | |
| 2731 | - toLocalString(m_program) + " " + toLocalString(m_custom_help); | |
| 2730 | + String result = m_help_string; | |
| 2731 | + if(print_usage) | |
| 2732 | + { | |
| 2733 | + result+= "\nUsage:\n " + toLocalString(m_program) + " " + toLocalString(m_custom_help); | |
| 2734 | + } | |
| 2732 | 2735 | |
| 2733 | 2736 | if (!m_positional.empty() && !m_positional_help.empty()) { |
| 2734 | 2737 | result += " " + toLocalString(m_positional_help); | ... | ... |