diff options
author | Jarryd Beck <jarro.2783@gmail.com> | 2022-01-14 08:16:31 +0300 |
---|---|---|
committer | Jarryd Beck <jarro.2783@gmail.com> | 2022-01-14 08:16:31 +0300 |
commit | 8d70323f8ecb3608633ef00458e60661b0833235 (patch) | |
tree | 3de70a66054e5df82b10a95177bbb7694c868991 | |
parent | ad2d1a6b5fd3fbb7bb0e7bc11f28a427494aea45 (diff) |
Add a program functionadd_program
Fixes 323. Adds a function to retrieve the program name.
-rw-r--r-- | include/cxxopts.hpp | 5 | ||||
-rw-r--r-- | test/options.cpp | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index d247ba7..2dd4da6 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -1825,6 +1825,11 @@ namespace cxxopts const HelpGroupDetails& group_help(const std::string& group) const; + const std::string& program() const + { + return m_program; + } + private: void diff --git a/test/options.cpp b/test/options.cpp index 610a6bc..3398b70 100644 --- a/test/options.cpp +++ b/test/options.cpp @@ -95,6 +95,8 @@ TEST_CASE("Basic options", "[options]") CHECK(arguments[3].key() == "av"); CHECK_THROWS_AS(result["nothing"].as<std::string>(), cxxopts::option_has_no_value_exception&); + + CHECK(options.program() == "tester"); } TEST_CASE("Short options", "[options]") |