| 777 | } |
| 778 | |
| 779 | void Console::performCommand(socket_native_type fd, std::string_view command) |
| 780 | { |
| 781 | std::vector<std::string> args = Console::Utility::split(command, ' '); |
| 782 | if (args.empty()) |
| 783 | { |
| 784 | throw std::runtime_error("Unknown command. Type 'help' for options\n"); |
| 785 | } |
| 786 | |
| 787 | auto it = _commands.find(Console::Utility::trim(args[0])); |
| 788 | if (it != _commands.end()) |
| 789 | { |
| 790 | std::string args2; |
| 791 | for (size_t i = 1; i < args.size(); ++i) |
| 792 | { |
| 793 | if (i > 1) |
| 794 | { |
| 795 | args2 += ' '; |
| 796 | } |
| 797 | args2 += Console::Utility::trim(args[i]); |
| 798 | } |
| 799 | auto cmd = it->second; |
| 800 | cmd->commandGeneric(fd, args2); |
| 801 | } |
| 802 | else |
| 803 | { |
| 804 | throw std::runtime_error(std::string{"Unknown command "}.append(command).append(". Type 'help' for options\n")); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | void Console::addClient() |
| 809 | { |