MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / main

Function main

edrav2/eprj/cli/samples/complete.cpp:41–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41int main()
42{
43 boost::asio::io_service ios;
44
45 // setup cli
46
47 auto rootMenu = make_unique< Menu >( "cli" );
48 rootMenu -> Add(
49 "hello",
50 [](std::ostream& out){ out << "Hello, world\n"; },
51 "Print hello world" );
52 rootMenu -> Add(
53 "hello_everysession",
54 [](std::ostream&){ Cli::cout() << "Hello, everybody" << std::endl; },
55 "Print hello everybody on all open sessions" );
56 rootMenu -> Add(
57 "answer",
58 [](int x, std::ostream& out){ out << "The answer is: " << x << "\n"; },
59 "Print the answer to Life, the Universe and Everything " );
60 rootMenu -> Add(
61 "color",
62 [](std::ostream& out){ out << "Colors ON\n"; SetColor(); },
63 "Enable colors in the cli" );
64 rootMenu -> Add(
65 "nocolor",
66 [](std::ostream& out){ out << "Colors OFF\n"; SetNoColor(); },
67 "Disable colors in the cli" );
68
69 auto subMenu = make_unique< Menu >( "sub" );
70 subMenu -> Add(
71 "hello",
72 [](std::ostream& out){ out << "Hello, submenu world\n"; },
73 "Print hello world in the submenu" );
74 subMenu -> Add(
75 "demo",
76 [](std::ostream& out){ out << "This is a sample!\n"; },
77 "Print a demo string" );
78
79 auto subSubMenu = make_unique< Menu >( "subsub" );
80 subSubMenu -> Add(
81 "hello",
82 [](std::ostream& out){ out << "Hello, subsubmenu world\n"; },
83 "Print hello world in the sub-submenu" );
84 subMenu -> Add( std::move(subSubMenu));
85
86 rootMenu -> Add( std::move(subMenu) );
87
88
89 Cli cli( std::move(rootMenu) );
90 // global exit action
91 cli.ExitAction( [](auto& out){ out << "Goodbye and thanks for all the fish.\n"; } );
92
93 CliLocalTerminalSession localSession(cli, ios, std::cout, 200);
94 localSession.ExitAction(
95 [&ios](auto& out) // session exit action
96 {
97 out << "Closing App...\n";
98 ios.stop();

Callers

nothing calls this directly

Calls 7

SetColorFunction · 0.85
SetNoColorFunction · 0.85
moveFunction · 0.50
AddMethod · 0.45
ExitActionMethod · 0.45
stopMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected