From 2abdd4af4db0c794eb7eedce65b6c330052bdf0a Mon Sep 17 00:00:00 2001 From: Yassir Najmaoui <43155068+yassirnajmaoui@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:50:13 -0400 Subject: Add option to display usage (#355) Make the usage displaying optional --- include/cxxopts.hpp | 11 +++++++---- 1 file 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& groups = {}) const; + help(const std::vector& groups = {}, bool print_usage=true) const; std::vector groups() const; @@ -2725,10 +2725,13 @@ Options::generate_all_groups_help(String& result) const inline std::string -Options::help(const std::vector& help_groups) const +Options::help(const std::vector& 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); -- cgit v1.2.3