diff options
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | include/cxxopts.hpp | 5 | ||||
-rw-r--r-- | test/options.cpp | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c50fae0..220717d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ This is the changelog for `cxxopts`, a C++11 library for parsing command line options. The project adheres to semantic versioning. +## Unreleased + +### Added + +* Add a `program()` function to retrieve the program name. + ## 3.0 ### Changed 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]") |