MCPcopy Create free account
hub / github.com/CLIUtils/CLI11 / main

Function main

examples/callback_passthrough.cpp:11–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <string>
10
11int 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}

Callers

nothing calls this directly

Calls 5

allow_extrasMethod · 0.80
callbackMethod · 0.80
parseMethod · 0.80
add_optionMethod · 0.45

Tested by

no test coverage detected