| 9 | #include <string> |
| 10 | |
| 11 | int main(int argc, char **argv) { |
| 12 | |
| 13 | CLI::App app("callback_passthrough"); |
| 14 | app.allow_extras(); |
| 15 | std::string argName; |
| 16 | std::string val; |
| 17 | app.add_option("--argname", argName, "the name of the custom command line argument"); |
| 18 | app.callback([&app, &val, &argName]() { |
| 19 | if(!argName.empty()) { |
| 20 | CLI::App subApp; |
| 21 | subApp.add_option("--" + argName, val, "custom argument option"); |
| 22 | subApp.parse(app.remaining_for_passthrough()); |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | CLI11_PARSE(app, argc, argv); |
| 27 | std::cout << "the value is now " << val << '\n'; |
| 28 | } |
nothing calls this directly
no test coverage detected