diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index 65b7006..7ba3fca 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -827,9 +827,6 @@ public: std::string get_usage_full() const { std::stringstream usage; - if (!m_is_required) { - usage << "["; - } usage << get_names_csv(); const std::string metavar = !m_metavar.empty() ? m_metavar : "VAR"; if (m_num_args_range.get_max() > 0) { @@ -838,9 +835,6 @@ public: usage << "..."; } } - if (!m_is_required) { - usage << "]"; - } return usage.str(); } @@ -1833,8 +1827,8 @@ private: if (not_help_or_version) { if (!opt.m_is_used) { throw std::runtime_error( - "Zero positional arguments expected, did you mean '" + - opt.get_usage_full() + "'"); + "Zero positional arguments expected, did you mean " + + opt.get_usage_full()); } } diff --git a/test/test_error_reporting.cpp b/test/test_error_reporting.cpp index fc23a96..5c1b022 100644 --- a/test/test_error_reporting.cpp +++ b/test/test_error_reporting.cpp @@ -23,14 +23,14 @@ TEST_CASE("Missing optional argument name" * test_suite("error_reporting")) { SUBCASE("Bad case") { REQUIRE_THROWS_WITH_AS( parser.parse_args({"test", "-a", "1", "2"}), - "Zero positional arguments expected, did you mean '[-b VAR]'", + "Zero positional arguments expected, did you mean -b VAR", std::runtime_error); } SUBCASE("Bad case 2") { REQUIRE_THROWS_WITH_AS( parser.parse_args({"test", "1", "2"}), - "Zero positional arguments expected, did you mean '[-a VAR]'", + "Zero positional arguments expected, did you mean -a VAR", std::runtime_error); } }