MCPcopy Create free account
hub / github.com/bfgroup/Lyra / main

Function main

tests/optional_arg_help_run_test.cpp:13–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "mini_test.hpp"
12
13int main(int, const char**)
14{
15 using namespace lyra;
16 bfg::mini_test::scope test;
17
18 {
19 bool show_help = false;
20 std::string message;
21 // Ex: <exe> --repeat=10 "Hello world."
22 auto cli
23 = lyra::cli()
24 | help(show_help)
25 | lyra::arg(message, "++message++").help("**message**");
26 std::ostringstream help_text;
27 help_text << cli ;
28 test
29 (REQUIRE(help_text.str().find("**message**") != std::string::npos))
30 (REQUIRE(help_text.str().find("[<++message++>]") != std::string::npos));
31 }
32
33 {
34 bool show_help = false;
35 std::string message;
36 // Ex: <exe> --repeat=10 "Hello world."
37 auto cli
38 = lyra::cli()
39 | help(show_help)
40 | lyra::arg(message, "++message++").help("**message**").required();
41 std::ostringstream help_text;
42 help_text << cli ;
43 test
44 (REQUIRE(help_text.str().find("**message**") != std::string::npos))
45 (REQUIRE(help_text.str().find("[<++message++>]") == std::string::npos))
46 (REQUIRE(help_text.str().find("++message++") != std::string::npos));
47 }
48
49 return test;
50}

Callers

nothing calls this directly

Calls 5

cliClass · 0.50
helpClass · 0.50
argClass · 0.50
helpMethod · 0.45
requiredMethod · 0.45

Tested by

no test coverage detected