summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-11-19 16:11:35 -0500
committerAdam <Adam@anope.org>2017-11-19 16:11:35 -0500
commit2fda0fff4655e92e388d7823e5b1c1f0c6bcfe2d (patch)
treeb2cde60f3c2c98782690d67d134263924f59cc78
parent3fb9bb5118a5c3c6c916a48feed0e069867f3133 (diff)
Add subcommand syntax help, and reference subcommand help in syntax error messages
-rw-r--r--include/commands.h8
-rw-r--r--modules/botserv/assign.cpp2
-rw-r--r--modules/botserv/badwords.cpp4
-rw-r--r--modules/botserv/bot.cpp2
-rw-r--r--modules/botserv/control.cpp2
-rw-r--r--modules/botserv/kick.cpp16
-rw-r--r--modules/botserv/set.cpp4
-rw-r--r--modules/chanserv/access.cpp32
-rw-r--r--modules/chanserv/akick.cpp18
-rw-r--r--modules/chanserv/clone.cpp2
-rw-r--r--modules/chanserv/enforce.cpp2
-rw-r--r--modules/chanserv/entrymsg.cpp4
-rw-r--r--modules/chanserv/flags.cpp2
-rw-r--r--modules/chanserv/list.cpp2
-rw-r--r--modules/chanserv/mode.cpp4
-rw-r--r--modules/chanserv/seen.cpp2
-rw-r--r--modules/chanserv/set.cpp20
-rw-r--r--modules/chanserv/topic.cpp2
-rw-r--r--modules/chanserv/xop.cpp18
-rw-r--r--modules/extra/stats/chanstats.cpp4
-rw-r--r--modules/fantasy.cpp2
-rw-r--r--modules/greet.cpp2
-rw-r--r--modules/hostserv/add.cpp2
-rw-r--r--modules/hostserv/ban.cpp2
-rw-r--r--modules/hostserv/request.cpp2
-rw-r--r--modules/hostserv/set.cpp2
-rw-r--r--modules/memoserv/ignore.cpp2
-rw-r--r--modules/memoserv/list.cpp2
-rw-r--r--modules/memoserv/read.cpp2
-rw-r--r--modules/memoserv/set.cpp9
-rw-r--r--modules/nickserv/ajoin.cpp4
-rw-r--r--modules/nickserv/cert.cpp4
-rw-r--r--modules/nickserv/info.cpp4
-rw-r--r--modules/nickserv/list.cpp2
-rw-r--r--modules/nickserv/logout.cpp2
-rw-r--r--modules/nickserv/register.cpp2
-rw-r--r--modules/nickserv/set.cpp16
-rw-r--r--modules/operserv/akill.cpp18
-rw-r--r--modules/operserv/chankill.cpp2
-rw-r--r--modules/operserv/config.cpp2
-rw-r--r--modules/operserv/defcon.cpp2
-rw-r--r--modules/operserv/dns.cpp2
-rw-r--r--modules/operserv/forbid.cpp2
-rw-r--r--modules/operserv/ignore.cpp16
-rw-r--r--modules/operserv/info.cpp22
-rw-r--r--modules/operserv/logsearch.cpp2
-rw-r--r--modules/operserv/news.cpp18
-rw-r--r--modules/operserv/noop.cpp2
-rw-r--r--modules/operserv/oper.cpp2
-rw-r--r--modules/operserv/session.cpp20
-rw-r--r--modules/operserv/set.cpp27
-rw-r--r--modules/operserv/sxline.cpp20
-rw-r--r--src/command.cpp27
53 files changed, 291 insertions, 104 deletions
diff --git a/include/commands.h b/include/commands.h
index 1d8ad09af..853a30b48 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -127,6 +127,7 @@ class CoreExport Command : public Service
/* Command requires that a user is executing it */
bool require_user = false;
+ static void SendHelpCommand(CommandSource &source, const Anope::string &subcommand);
public:
static constexpr const char *NAME = "Command";
@@ -157,7 +158,12 @@ class CoreExport Command : public Service
void AllowUnregistered(bool b);
void RequireUser(bool b);
+ /**
+ * send the syntax for this command
+ */
void SendSyntax(CommandSource &);
+ void SubcommandSyntaxError(CommandSource &source, const Anope::string &subcommand, const Anope::string &syntax);
+
bool AllowUnregistered() const;
bool RequireUser() const;
@@ -189,7 +195,7 @@ class CoreExport Command : public Service
* @param source The source
* @param subcommand The subcommand the user tried to use
*/
- virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand);
+ virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand = "");
/** Runs a command
* @param source The source of the command
diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp
index 469f1f051..302977749 100644
--- a/modules/botserv/assign.cpp
+++ b/modules/botserv/assign.cpp
@@ -206,7 +206,7 @@ class CommandBSSetNoBot : public Command
}
else
{
- this->OnSyntaxError(source, source.GetCommand());
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/botserv/badwords.cpp b/modules/botserv/badwords.cpp
index d504763be..c270d91d2 100644
--- a/modules/botserv/badwords.cpp
+++ b/modules/botserv/badwords.cpp
@@ -336,7 +336,7 @@ class CommandBSBadwords : public Command
if (!need_args && word.empty())
{
- this->OnSyntaxError(source, cmd);
+ this->OnSyntaxError(source);
return;
}
@@ -368,7 +368,7 @@ class CommandBSBadwords : public Command
else if (cmd.equals_ci("CLEAR"))
this->DoClear(source, ci);
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/botserv/bot.cpp b/modules/botserv/bot.cpp
index 21a5f6ce9..65a891839 100644
--- a/modules/botserv/bot.cpp
+++ b/modules/botserv/bot.cpp
@@ -380,7 +380,7 @@ class CommandBSBot : public Command
}
else
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/botserv/control.cpp b/modules/botserv/control.cpp
index 758f795f2..48d5cd9f6 100644
--- a/modules/botserv/control.cpp
+++ b/modules/botserv/control.cpp
@@ -68,7 +68,7 @@ class CommandBSSay : public Command
if (text[0] == '\001')
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
return;
}
diff --git a/modules/botserv/kick.cpp b/modules/botserv/kick.cpp
index 7c7eb3829..080303e68 100644
--- a/modules/botserv/kick.cpp
+++ b/modules/botserv/kick.cpp
@@ -523,7 +523,7 @@ class CommandBSKick : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -583,9 +583,9 @@ class CommandBSKickBase : public Command
else if (ci == NULL)
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
else if (option.empty())
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
else if (!option.equals_ci("ON") && !option.equals_ci("OFF"))
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasOverridePriv("botserv/administration"))
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName());
else if (!ci->GetBot())
@@ -648,7 +648,7 @@ class CommandBSKickBase : public Command
source.Reply(_("Bot won't kick for \002{0}\002 anymore."), optname);
}
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
};
@@ -896,7 +896,7 @@ class CommandBSKickFlood : public CommandBSKickBase
}
else
{
- this->OnSyntaxError(source, params[1]);
+ this->OnSyntaxError(source);
}
}
@@ -998,7 +998,7 @@ class CommandBSKickRepeat : public CommandBSKickBase
}
else
{
- this->OnSyntaxError(source, params[1]);
+ this->OnSyntaxError(source);
}
}
@@ -1110,7 +1110,7 @@ class CommandBSSetDontKickOps : public Command
}
else
{
- this->OnSyntaxError(source, source.GetCommand());
+ this->OnSyntaxError(source);
}
}
@@ -1174,7 +1174,7 @@ class CommandBSSetDontKickVoices : public Command
}
else
{
- this->OnSyntaxError(source, source.GetCommand());
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/botserv/set.cpp b/modules/botserv/set.cpp
index 638aac012..d137882a6 100644
--- a/modules/botserv/set.cpp
+++ b/modules/botserv/set.cpp
@@ -31,7 +31,7 @@ class CommandBSSet : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -191,7 +191,7 @@ class CommandBSSetPrivate : public Command
}
else
{
- this->OnSyntaxError(source, source.GetCommand());
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp
index 886f02778..fd6aad1c5 100644
--- a/modules/chanserv/access.cpp
+++ b/modules/chanserv/access.cpp
@@ -625,6 +625,22 @@ class CommandCSAccess : public Command
return true;
}
+
+ void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) override
+ {
+ if (subcommand.equals_ci("ADD"))
+ {
+ SubcommandSyntaxError(source, subcommand, _("\037mask\037 \037level\037"));
+ }
+ else if (subcommand.equals_ci("DEL"))
+ {
+ SubcommandSyntaxError(source, subcommand, _("{\037mask\037 | \037entry-num\037 | \037list\037}"));
+ }
+ else
+ {
+ Command::OnSyntaxError(source, subcommand);
+ }
+ }
};
class CommandCSLevels : public Command
@@ -873,6 +889,22 @@ class CommandCSLevels : public Command
}
return true;
}
+
+ void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) override
+ {
+ if (subcommand.equals_ci("SET"))
+ {
+ SubcommandSyntaxError(source, subcommand, "\037privilege\037 \037level\037");
+ }
+ else if (subcommand.equals_ci("DISABLE"))
+ {
+ SubcommandSyntaxError(source, subcommand, "\037privilege\037");
+ }
+ else
+ {
+ Command::OnSyntaxError(source, subcommand);
+ }
+ }
};
class CSAccess : public Module
diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp
index bbdd614e5..b099c48ac 100644
--- a/modules/chanserv/akick.cpp
+++ b/modules/chanserv/akick.cpp
@@ -599,7 +599,7 @@ class CommandCSAKick : public Command
else if (cmd.equals_ci("CLEAR"))
this->DoClear(source, ci);
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -678,6 +678,22 @@ class CommandCSAKick : public Command
return true;
}
+
+ void OnSyntaxError(CommandSource &source, const Anope::string &subcommand = "") override
+ {
+ if (subcommand.equals_ci("ADD"))
+ {
+ SubcommandSyntaxError(source, subcommand, _("{\037nick\037 | \037mask\037} [\037reason\037]"));
+ }
+ else if (subcommand.equals_ci("DEL"))
+ {
+ SubcommandSyntaxError(source, subcommand, _("{\037nick\037 | \037mask\037 | \037entry-num\037 | \037list\037}"));
+ }
+ else
+ {
+ Command::OnSyntaxError(source, subcommand);
+ }
+ }
};
class CSAKick : public Module
diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp
index 341d80944..a5af50743 100644
--- a/modules/chanserv/clone.cpp
+++ b/modules/chanserv/clone.cpp
@@ -198,7 +198,7 @@ public:
}
else
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
return;
}
diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp
index c9ca14acf..d31cb8ce7 100644
--- a/modules/chanserv/enforce.cpp
+++ b/modules/chanserv/enforce.cpp
@@ -271,7 +271,7 @@ class CommandCSEnforce : public Command
else if (what.equals_ci("LIMIT"))
this->DoLimit(source, ci);
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp
index efcea8e9d..f7beca19f 100644
--- a/modules/chanserv/entrymsg.cpp
+++ b/modules/chanserv/entrymsg.cpp
@@ -241,13 +241,13 @@ class CommandEntryMessage : public Command
else if (params[1].equals_ci("CLEAR"))
this->DoClear(source, ci);
else if (params.size() < 3)
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
else if (params[1].equals_ci("ADD"))
this->DoAdd(source, ci, params[2]);
else if (params[1].equals_ci("DEL"))
this->DoDel(source, ci, params[2]);
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/chanserv/flags.cpp b/modules/chanserv/flags.cpp
index ecd8ba9d3..c1ebe412f 100644
--- a/modules/chanserv/flags.cpp
+++ b/modules/chanserv/flags.cpp
@@ -101,7 +101,7 @@ class CommandCSFlags : public Command
{
if (flags.empty())
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
return;
}
diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp
index 1f89b0274..972099610 100644
--- a/modules/chanserv/list.cpp
+++ b/modules/chanserv/list.cpp
@@ -229,7 +229,7 @@ class CommandCSSetPrivate : public Command
}
else
{
- this->OnSyntaxError(source, "PRIVATE");
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp
index b1639baa0..e72273397 100644
--- a/modules/chanserv/mode.cpp
+++ b/modules/chanserv/mode.cpp
@@ -486,7 +486,7 @@ class CommandCSMode : public Command
}
else
{
- this->OnSyntaxError(source, subcommand);
+ this->OnSyntaxError(source);
}
}
@@ -755,7 +755,7 @@ class CommandCSMode : public Command
}
else
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/chanserv/seen.cpp b/modules/chanserv/seen.cpp
index db52f269e..87c8c9907 100644
--- a/modules/chanserv/seen.cpp
+++ b/modules/chanserv/seen.cpp
@@ -153,7 +153,7 @@ class CommandOSSeen : public Command
time_t time = 0;
if ((params.size() < 2) || (0 >= (time = Anope::DoTime(params[1]))))
{
- this->OnSyntaxError(source, params[0]);
+ this->OnSyntaxError(source, "CLEAR");
return;
}
time = Anope::CurTime - time;
diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp
index dbe17f0ab..c6df83cbe 100644
--- a/modules/chanserv/set.cpp
+++ b/modules/chanserv/set.cpp
@@ -33,7 +33,7 @@ class CommandCSSet : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -128,7 +128,7 @@ class CommandCSSetAutoOp : public Command
}
else
{
- this->OnSyntaxError(source, "AUTOOP");
+ this->OnSyntaxError(source);
}
}
@@ -401,7 +401,7 @@ class CommandCSSetKeepModes : public Command
}
else
{
- this->OnSyntaxError(source, "KEEPMODES");
+ this->OnSyntaxError(source);
}
}
@@ -466,7 +466,7 @@ class CommandCSSetPeace : public Command
}
else
{
- this->OnSyntaxError(source, "PEACE");
+ this->OnSyntaxError(source);
}
}
@@ -605,7 +605,7 @@ class CommandCSSetPersist : public Command
}
else
{
- this->OnSyntaxError(source, "PERSIST");
+ this->OnSyntaxError(source);
}
}
@@ -671,7 +671,7 @@ class CommandCSSetRestricted : public Command
}
else
{
- this->OnSyntaxError(source, "RESTRICTED");
+ this->OnSyntaxError(source);
}
}
@@ -736,7 +736,7 @@ class CommandCSSetSecureFounder : public Command
}
else
{
- this->OnSyntaxError(source, "SECUREFOUNDER");
+ this->OnSyntaxError(source);
}
}
@@ -806,7 +806,7 @@ class CommandCSSetSecureOps : public Command
}
else
{
- this->OnSyntaxError(source, "SECUREOPS");
+ this->OnSyntaxError(source);
}
}
@@ -882,7 +882,7 @@ class CommandCSSetSignKick : public Command
}
else
{
- this->OnSyntaxError(source, "SIGNKICK");
+ this->OnSyntaxError(source);
}
}
@@ -1024,7 +1024,7 @@ class CommandCSSetNoexpire : public Command
}
else
{
- this->OnSyntaxError(source, "NOEXPIRE");
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp
index 85bcf1426..d103307ce 100644
--- a/modules/chanserv/topic.cpp
+++ b/modules/chanserv/topic.cpp
@@ -76,7 +76,7 @@ class CommandCSSetKeepTopic : public Command
}
else
{
- this->OnSyntaxError(source, "KEEPTOPIC");
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/chanserv/xop.cpp b/modules/chanserv/xop.cpp
index 26de3ec41..ad6990a9a 100644
--- a/modules/chanserv/xop.cpp
+++ b/modules/chanserv/xop.cpp
@@ -479,7 +479,7 @@ class CommandCSXOP : public Command
else if (cmd.equals_ci("CLEAR"))
return this->DoClear(source, ci);
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
@@ -574,6 +574,22 @@ class CommandCSXOP : public Command
}
return true;
}
+
+ void OnSyntaxError(CommandSource &source, const Anope::string &subcommand = "") override
+ {
+ if (subcommand.equals_ci("ADD"))
+ {
+ SubcommandSyntaxError(source, subcommand, _("\037channel\037 ADD \037mask\037"));
+ }
+ else if (subcommand.equals_ci("DEL"))
+ {
+ SubcommandSyntaxError(source, subcommand, _("{\037mask\037 | \037entry-num\037 | \037list\037}"));
+ }
+ else
+ {
+ Command::OnSyntaxError(source, subcommand);
+ }
+ }
};
class CSXOP : public Module
diff --git a/modules/extra/stats/chanstats.cpp b/modules/extra/stats/chanstats.cpp
index adc002c8c..3e40f7c31 100644
--- a/modules/extra/stats/chanstats.cpp
+++ b/modules/extra/stats/chanstats.cpp
@@ -43,7 +43,7 @@ class CommandCSSetChanstats : public Command
source.Reply(_("Chanstats statistics are now disabled for this channel."));
}
else
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &source, const Anope::string &) override
@@ -96,7 +96,7 @@ class CommandNSSetChanstats : public Command
source.Reply(_("Chanstats statistics are now disabled for your nick."));
}
else
- this->OnSyntaxError(source, "CHANSTATS");
+ this->OnSyntaxError(source);
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
diff --git a/modules/fantasy.cpp b/modules/fantasy.cpp
index e3556716c..ce2ad5a1d 100644
--- a/modules/fantasy.cpp
+++ b/modules/fantasy.cpp
@@ -69,7 +69,7 @@ class CommandBSSetFantasy : public Command
}
else
{
- this->OnSyntaxError(source, source.GetCommand());
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/greet.cpp b/modules/greet.cpp
index e4026825b..26ad7e899 100644
--- a/modules/greet.cpp
+++ b/modules/greet.cpp
@@ -71,7 +71,7 @@ class CommandBSSetGreet : public Command
}
else
{
- this->OnSyntaxError(source, source.GetCommand());
+ this->OnSyntaxError(source);
}
}
diff --git a/modules/hostserv/add.cpp b/modules/hostserv/add.cpp
index 9ad20c44b..bdb29557e 100644
--- a/modules/hostserv/add.cpp
+++ b/modules/hostserv/add.cpp
@@ -63,7 +63,7 @@ class CommandHSAdd : public Command
if (host.empty())
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
return;
}
diff --git a/modules/hostserv/ban.cpp b/modules/hostserv/ban.cpp
index d85da4ca1..2b6450a85 100644
--- a/modules/hostserv/ban.cpp
+++ b/modules/hostserv/ban.cpp
@@ -144,7 +144,7 @@ class CommandHSBan : public Command
if (reason.empty())
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
return;
}
diff --git a/modules/hostserv/request.cpp b/modules/hostserv/request.cpp
index d5a3de0ae..7f87e2e21 100644
--- a/modules/hostserv/request.cpp
+++ b/modules/hostserv/request.cpp
@@ -169,7 +169,7 @@ class CommandHSRequest : public Command
if (host.empty())
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
return;
}
diff --git a/modules/hostserv/set.cpp b/modules/hostserv/set.cpp
index 4b506165e..15f05784e 100644
--- a/modules/hostserv/set.cpp
+++ b/modules/hostserv/set.cpp
@@ -30,7 +30,7 @@ class CommandHSSet : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
- this->OnSyntaxError(source, "");
+ this->OnSyntaxError(source);
}
bool OnHelp(CommandSource &a