MCPcopy Create free account
hub / github.com/daniele77/cli / main

Function main

examples/pluginmanager.cpp:253–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251// Entry point
252
253int main()
254{
255 try
256 {
257 CmdHandler colorCmd;
258 CmdHandler nocolorCmd;
259
260 // setup cli
261
262 auto rootMenu = make_unique< Menu >( "cli" );
263 PluginContainer::Instance().SetMenu(*rootMenu);
264 rootMenu->Insert(
265 "list",
266 [](std::ostream& out){ PluginRegistry::Instance().Print(out); },
267 "Print the plugin list" );
268 rootMenu->Insert(
269 "loaded",
270 [](std::ostream& out)
271 {
272 PluginContainer::Instance().PrintLoaded(out);
273 },
274 "Load the plugin specified" );
275 rootMenu->Insert(
276 "load", {"plugin_name"},
277 [](std::ostream&, const string& plugin)
278 {
279 PluginContainer::Instance().Load(plugin);
280 },
281 "Load the plugin specified" );
282 rootMenu->Insert(
283 "unload", {"plugin_name"},
284 [](std::ostream&, const string& plugin)
285 {
286 PluginContainer::Instance().Unload(plugin);
287 },
288 "Unload the plugin specified" );
289 colorCmd = rootMenu -> Insert(
290 "color",
291 [&](std::ostream& out)
292 {
293 out << "Colors ON\n";
294 SetColor();
295 colorCmd.Disable();
296 nocolorCmd.Enable();
297 },
298 "Enable colors in the cli" );
299 nocolorCmd = rootMenu -> Insert(
300 "nocolor",
301 [&](std::ostream& out)
302 {
303 out << "Colors OFF\n";
304 SetNoColor();
305 colorCmd.Enable();
306 nocolorCmd.Disable();
307 },
308 "Disable colors in the cli" );
309
310

Callers

nothing calls this directly

Calls 14

SetColorFunction · 0.85
SetNoColorFunction · 0.85
SetMenuMethod · 0.80
PrintMethod · 0.80
PrintLoadedMethod · 0.80
LoadMethod · 0.80
UnloadMethod · 0.80
whatMethod · 0.80
InsertMethod · 0.45
DisableMethod · 0.45
EnableMethod · 0.45
ExitActionMethod · 0.45

Tested by

no test coverage detected