MCPcopy Create free account
hub / github.com/axmolengine/axmol / commandGeneric

Method commandGeneric

core/base/Console.cpp:309–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309void Console::Command::commandGeneric(int fd, std::string_view args)
310{
311 // The first argument (including the empty)
312 std::string key(args);
313 auto pos = args.find(' ');
314 if ((pos != std::string::npos) && (0 < pos))
315 {
316 key = args.substr(0, pos);
317 }
318
319 // help
320 if (key == "help" || key == "-h")
321 {
322 commandHelp(fd, args);
323 return;
324 }
325
326 // find sub command
327 auto it = _subCommands.find(key);
328 if (it != _subCommands.end())
329 {
330 auto subCmd = it->second;
331 if (subCmd->_callback)
332 {
333 subCmd->_callback(fd, args);
334 }
335 return;
336 }
337
338 // can not find
339 if (_callback)
340 {
341 _callback(fd, args);
342 }
343}
344
345//
346// Console code

Callers 1

performCommandMethod · 0.80

Calls 3

findMethod · 0.45
substrMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected