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:
authorJarryd Beck <jarro.2783@gmail.com>2022-01-14 08:16:31 +0300
committerJarryd Beck <jarro.2783@gmail.com>2022-01-14 08:26:48 +0300
commit4e208b95b7ae488b0d31fcc80228b141792b79b5 (patch)
tree08fb89c74b2b245bd7e841923f5c8851a76a5fb7
parentad2d1a6b5fd3fbb7bb0e7bc11f28a427494aea45 (diff)
Add a program function
Fixes 323. Adds a function to retrieve the program name.
-rw-r--r--CHANGELOG.md6
-rw-r--r--include/cxxopts.hpp5
-rw-r--r--test/options.cpp2
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]")