| 367 | } |
| 368 | |
| 369 | void CommandSystem::executeCommand(const std::string& name, const ArgumentList& args) |
| 370 | { |
| 371 | // Find the named command |
| 372 | auto i = _commands.find(name); |
| 373 | |
| 374 | if (i == _commands.end()) |
| 375 | { |
| 376 | rError() << "Cannot execute command " << name << ": Command not found." << std::endl; |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | try |
| 381 | { |
| 382 | i->second->execute(args); |
| 383 | } |
| 384 | catch (const ExecutionNotPossible& ex) |
| 385 | { |
| 386 | rError() << "Command '" << name << "' cannot be executed: " << ex.what() << std::endl; |
| 387 | |
| 388 | // Dispatch this exception to the messagebus to potential listeners |
| 389 | radiant::CommandExecutionFailedMessage message(ex); |
| 390 | GlobalRadiantCore().getMessageBus().sendMessage(message); |
| 391 | } |
| 392 | catch (const ExecutionFailure& ex) |
| 393 | { |
| 394 | rError() << "Command '" << name << "' failed: " << ex.what() << std::endl; |
| 395 | |
| 396 | // Dispatch this exception to the messagebus to potential listeners |
| 397 | radiant::CommandExecutionFailedMessage message(ex); |
| 398 | GlobalRadiantCore().getMessageBus().sendMessage(message); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | AutoCompletionInfo CommandSystem::getAutoCompletionInfo(const std::string& prefix) { |
| 403 | AutoCompletionInfo returnValue; |