This example demonstrates the use of `prefix_command` on a subcommand to capture all subsequent arguments along with an alias to make it appear as a regular options. All the values after the "sub" or "--sub" are available in the remaining() method. */
| 16 | All the values after the "sub" or "--sub" are available in the remaining() method. |
| 17 | */ |
| 18 | int main(int argc, const char *argv[]) { |
| 19 | |
| 20 | int value{0}; |
| 21 | CLI::App app{"Test App"}; |
| 22 | app.add_option("-v", value, "value"); |
| 23 | |
| 24 | auto *subcom = app.add_subcommand("sub", "")->prefix_command(); |
| 25 | subcom->alias("--sub"); |
| 26 | CLI11_PARSE(app, argc, argv); |
| 27 | |
| 28 | std::cout << "value=" << value << '\n'; |
| 29 | std::cout << "after Args:"; |
| 30 | for(const auto &aarg : subcom->remaining()) { |
| 31 | std::cout << aarg << " "; |
| 32 | } |
| 33 | std::cout << '\n'; |
| 34 | } |
nothing calls this directly
no test coverage detected