Commit 7c468aaf68206f0f05fcf6c436ed274da138bdbc
1 parent
95a48de8
Allow iterator inputs to parse_positional
Showing
3 changed files
with
13 additions
and
1 deletions
CHANGELOG.md
| @@ -9,6 +9,10 @@ options. The project adheres to semantic versioning. | @@ -9,6 +9,10 @@ options. The project adheres to semantic versioning. | ||
| 9 | 9 | ||
| 10 | * Allow integers to have leading zeroes. | 10 | * Allow integers to have leading zeroes. |
| 11 | 11 | ||
| 12 | +### Added | ||
| 13 | + | ||
| 14 | +* Iterator inputs to `parse_positional`. | ||
| 15 | + | ||
| 12 | ### Bug Fixes | 16 | ### Bug Fixes |
| 13 | 17 | ||
| 14 | * Fix a warning about possible loss of data. | 18 | * Fix a warning about possible loss of data. |
include/cxxopts.hpp
| @@ -1255,6 +1255,12 @@ namespace cxxopts | @@ -1255,6 +1255,12 @@ namespace cxxopts | ||
| 1255 | void | 1255 | void |
| 1256 | parse_positional(std::initializer_list<std::string> options); | 1256 | parse_positional(std::initializer_list<std::string> options); |
| 1257 | 1257 | ||
| 1258 | + template <typename Iterator> | ||
| 1259 | + void | ||
| 1260 | + parse_positional(Iterator begin, Iterator end) { | ||
| 1261 | + parse_positional(std::vector<std::string>{begin, end}); | ||
| 1262 | + } | ||
| 1263 | + | ||
| 1258 | std::string | 1264 | std::string |
| 1259 | help(const std::vector<std::string>& groups = {""}) const; | 1265 | help(const std::vector<std::string>& groups = {""}) const; |
| 1260 | 1266 |
test/options.cpp
| @@ -145,7 +145,9 @@ TEST_CASE("All positional", "[positional]") | @@ -145,7 +145,9 @@ TEST_CASE("All positional", "[positional]") | ||
| 145 | auto argc = av.argc(); | 145 | auto argc = av.argc(); |
| 146 | auto argv = av.argv(); | 146 | auto argv = av.argv(); |
| 147 | 147 | ||
| 148 | - options.parse_positional({"positional"}); | 148 | + std::vector<std::string> pos_names = {"positional"}; |
| 149 | + | ||
| 150 | + options.parse_positional(pos_names.begin(), pos_names.end()); | ||
| 149 | 151 | ||
| 150 | auto result = options.parse(argc, argv); | 152 | auto result = options.parse(argc, argv); |
| 151 | 153 |