Files
sophia/engine/include/sophia/console/console_command_registry.hpp
T

36 lines
696 B
C++

#pragma once
#include <functional>
#include <map>
#include <string>
#include <vector>
namespace sophia {
class ConsoleCommandRegistry {
public:
using Handler = std::function<std::string(const std::vector<std::string>&)>;
struct CommandInfo {
std::string name;
std::string help;
};
void registerCommand(std::string name, std::string help, Handler handler);
bool dispatch(const std::string& name, const std::vector<std::string>& args,
std::string& outResult) const;
std::vector<CommandInfo> list() const;
private:
struct Command {
std::string help;
Handler handler;
};
std::map<std::string, Command> commands;
};
} // namespace sophia