Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jarro2783/cxxopts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYassir Najmaoui <43155068+yassirnajmaoui@users.noreply.github.com>2022-07-27 23:50:13 +0300
committerGitHub <noreply@github.com>2022-07-27 23:50:13 +0300
commit2abdd4af4db0c794eb7eedce65b6c330052bdf0a (patch)
tree596b63fcb1e99531381fe216416bc9474eca3a5c
parent01798ee7a09fca55cf770c94a3bea8a670ea4a7d (diff)
Add option to display usage (#355)
Make the usage displaying optional
-rw-r--r--include/cxxopts.hpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp
index 284ddf8..07646da 100644
--- a/include/cxxopts.hpp
+++ b/include/cxxopts.hpp
@@ -1893,7 +1893,7 @@ class Options
}
std::string
- help(const std::vector<std::string>& groups = {}) const;
+ help(const std::vector<std::string>& groups = {}, bool print_usage=true) const;
std::vector<std::string>
groups() const;
@@ -2725,10 +2725,13 @@ Options::generate_all_groups_help(String& result) const
inline
std::string
-Options::help(const std::vector<std::string>& help_groups) const
+Options::help(const std::vector<std::string>& help_groups, bool print_usage) const
{
- String result = m_help_string + "\nUsage:\n " +
- toLocalString(m_program) + " " + toLocalString(m_custom_help);
+ String result = m_help_string;
+ if(print_usage)
+ {
+ result+= "\nUsage:\n " + toLocalString(m_program) + " " + toLocalString(m_custom_help);
+ }
if (!m_positional.empty() && !m_positional_help.empty()) {
result += " " + toLocalString(m_positional_help);