Commit f0f465b20f211048dd1c08293bde3de14dc1e4f4
1 parent
8185e6bb
Add unmatched arguments to example
Ref #242. Adds an example in the example file showing the unmatched arguments that are stored.
Showing
1 changed file
with
7 additions
and
0 deletions
src/example.cpp
| @@ -173,6 +173,13 @@ parse(int argc, const char* argv[]) | @@ -173,6 +173,13 @@ parse(int argc, const char* argv[]) | ||
| 173 | 173 | ||
| 174 | auto arguments = result.arguments(); | 174 | auto arguments = result.arguments(); |
| 175 | std::cout << "Saw " << arguments.size() << " arguments" << std::endl; | 175 | std::cout << "Saw " << arguments.size() << " arguments" << std::endl; |
| 176 | + | ||
| 177 | + std::cout << "Unmatched options: "; | ||
| 178 | + for (const auto& option: result.unmatched()) | ||
| 179 | + { | ||
| 180 | + std::cout << "'" << option << "' "; | ||
| 181 | + } | ||
| 182 | + std::cout << std::endl; | ||
| 176 | } | 183 | } |
| 177 | catch (const cxxopts::OptionException& e) | 184 | catch (const cxxopts::OptionException& e) |
| 178 | { | 185 | { |