Skip to content

Commit

Permalink
Add a program function
Browse files Browse the repository at this point in the history
Fixes 323. Adds a function to retrieve the program name.
  • Loading branch information
jarro2783 committed Jan 14, 2022
1 parent ad2d1a6 commit 4e208b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions include/cxxopts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down

0 comments on commit 4e208b9

Please sign in to comment.