| 580 | } |
| 581 | |
| 582 | void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) |
| 583 | { |
| 584 | if (command->ArgC() >= 3) |
| 585 | { |
| 586 | const char *text = command->Arg(2); |
| 587 | |
| 588 | IPlugin *pPlugin = scripts->FindPluginByConsoleArg(text); |
| 589 | |
| 590 | if (!pPlugin) |
| 591 | { |
| 592 | UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", text); |
| 593 | return; |
| 594 | } |
| 595 | |
| 596 | const sm_plugininfo_t *plinfo = pPlugin->GetPublicInfo(); |
| 597 | const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : pPlugin->GetFilename(); |
| 598 | |
| 599 | PluginHookList *pList; |
| 600 | if (!pPlugin->GetProperty("CommandList", (void **)&pList)) |
| 601 | { |
| 602 | UTIL_ConsolePrint("[SM] No commands found for: %s", plname); |
| 603 | return; |
| 604 | } |
| 605 | if (pList->empty()) |
| 606 | { |
| 607 | UTIL_ConsolePrint("[SM] No commands found for: %s", plname); |
| 608 | return; |
| 609 | } |
| 610 | |
| 611 | const char *type = NULL; |
| 612 | const char *name; |
| 613 | const char *help; |
| 614 | UTIL_ConsolePrint("[SM] Listing commands for: %s", plname); |
| 615 | UTIL_ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]"); |
| 616 | for (PluginHookList::iterator iter = pList->begin(); iter != pList->end(); iter++) |
| 617 | { |
| 618 | CmdHook *hook = *iter; |
| 619 | if (hook->type == CmdHook::Server) |
| 620 | type = "server"; |
| 621 | else |
| 622 | type = hook->info->eflags == 0 ? "console" : "admin"; |
| 623 | |
| 624 | name = hook->info->pCmd->GetName(); |
| 625 | if (hook->helptext.length()) |
| 626 | help = hook->helptext.c_str(); |
| 627 | else |
| 628 | help = hook->info->pCmd->GetHelpText(); |
| 629 | UTIL_ConsolePrint(" %-17.16s %-12.11s %s", name, type, help); |
| 630 | } |
| 631 | |
| 632 | return; |
| 633 | } |
| 634 | |
| 635 | UTIL_ConsolePrint("[SM] Usage: sm cmds <plugin #>"); |
| 636 | } |
nothing calls this directly
no test coverage detected