diff options
author | Adam <Adam@anope.org> | 2013-01-13 22:05:30 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-01-13 22:07:27 -0500 |
commit | da6543d17b689c31226e1b7ba1ce7de29baee2df (patch) | |
tree | 750c38fc64ac41a93c9eb539637ae029239855fd /src | |
parent | 29a018088ecf42c870b78d1539a90776a21276ec (diff) |
Allow grouping commands to make help output easier to comprehend
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 3 | ||||
-rw-r--r-- | src/config.cpp | 46 |
2 files changed, 44 insertions, 5 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index b796828a4..ef8514c87 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -251,12 +251,13 @@ void BotInfo::OnMessage(User *u, const Anope::string &message) RunCommand(source, message); } -void BotInfo::SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission) +CommandInfo& BotInfo::SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission) { CommandInfo ci; ci.name = sname; ci.permission = permission; this->commands[cname] = ci; + return this->commands[cname]; } CommandInfo *BotInfo::GetCommand(const Anope::string &cname) diff --git a/src/config.cpp b/src/config.cpp index 6c99e9c6e..bdd7180da 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -819,6 +819,8 @@ static bool DoCommands(ServerConfig *config, const Anope::string &, const Anope: Anope::string name = values[1].GetValue(); Anope::string command = values[2].GetValue(); Anope::string permission = values[3].GetValue(); + Anope::string group = values[4].GetValue(); + bool hide = values[5].GetBool(); ValueItem vi(service); if (!ValidateNotEmpty(config, "command", "service", vi)) @@ -839,7 +841,9 @@ static bool DoCommands(ServerConfig *config, const Anope::string &, const Anope: if (bi->commands.count(name)) throw ConfigException("Command name " + name + " already exists on " + bi->nick); - bi->SetCommand(name, command, permission); + CommandInfo &ci = bi->SetCommand(name, command, permission); + ci.group = group; + ci.hide = hide; return true; } @@ -1026,6 +1030,35 @@ static bool DoneFantasy(ServerConfig *config, const Anope::string &) /*************************************************************************/ +static bool InitCommandGroups(ServerConfig *config, const Anope::string &) +{ + config->CommandGroups.clear(); + return true; +} + +static bool DoCommandGroups(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *) +{ + Anope::string name = values[0].GetValue(); + Anope::string description = values[1].GetValue(); + + if (name.empty() || description.empty()) + return true; + + CommandGroup gr; + gr.name = name; + gr.description = description; + + config->CommandGroups.push_back(gr); + return true; +} + +static bool DoneCommandGroups(ServerConfig *config, const Anope::string &) +{ + return true; +} + +/*************************************************************************/ + ConfigurationFile::ConfigurationFile(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL) { } @@ -1340,9 +1373,9 @@ ConfigItems::ConfigItems(ServerConfig *conf) {DT_STRING, DT_STRING, DT_INTEGER, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN, DT_BOOLEAN}, InitLogs, DoLogs, DoneLogs}, {"command", - {"service", "name", "command", "permission", ""}, - {"", "", "", "", ""}, - {DT_STRING, DT_STRING, DT_STRING, DT_STRING}, + {"service", "name", "command", "permission", "group", "hide", ""}, + {"", "", "", "", "", "no", ""}, + {DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN}, InitCommands, DoCommands, DoneCommands}, {"privilege", {"name", "desc", "rank", ""}, @@ -1354,6 +1387,11 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"", "", "", "yes", ""}, {DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN}, InitFantasy, DoFantasy, DoneFantasy}, + {"command_group", + {"name", "description", ""}, + {"", "", ""}, + {DT_STRING, DT_STRING}, + InitCommandGroups, DoCommandGroups, DoneCommandGroups}, {"", {""}, {""}, |