mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Allow wildcards in help command args
Supports the help command for *status, all modules that are using CModCommand as appropriate, and *controlpanel get/set variables.
This commit is contained in:
@@ -51,7 +51,7 @@ class CAdminMod : public CModule {
|
||||
const CString sCmdFilter = sLine.Token(1, false);
|
||||
const CString::size_type iCmdLength = sCmdFilter.size();
|
||||
|
||||
const CString sVarFilter = sLine.Token(2, true);
|
||||
const CString sVarFilter = sLine.Token(2, true).AsLower();
|
||||
const CString::size_type iVarLength = sVarFilter.size();
|
||||
|
||||
if (sCmdFilter.empty() || sCmdFilter.Equals("Set", false, iCmdLength) || sCmdFilter.Equals("Get", false, iCmdLength)) {
|
||||
@@ -89,7 +89,8 @@ class CAdminMod : public CModule {
|
||||
#endif
|
||||
};
|
||||
for (unsigned int i = 0; i != ARRAY_SIZE(vars); ++i) {
|
||||
if (sVarFilter.empty() || sVarFilter.Equals(vars[i][0], false, iVarLength)) {
|
||||
CString sVar = CString(vars[i][0]).AsLower();
|
||||
if (sVarFilter.empty() || sVarFilter.Equals(sVar, true, iVarLength) || sVar.WildCmp(sVarFilter)) {
|
||||
VarTable.AddRow();
|
||||
VarTable.SetCell("Variable", vars[i][0]);
|
||||
VarTable.SetCell("Type", vars[i][1]);
|
||||
@@ -118,7 +119,8 @@ class CAdminMod : public CModule {
|
||||
#endif
|
||||
};
|
||||
for (unsigned int i = 0; i != ARRAY_SIZE(nvars); ++i) {
|
||||
if (sVarFilter.empty() || sVarFilter.Equals(nvars[i][0], false, iVarLength)) {
|
||||
CString sVar = CString(nvars[i][0]).AsLower();
|
||||
if (sVarFilter.empty() || sVarFilter.Equals(sVar, true, iVarLength) || sVar.WildCmp(sVarFilter)) {
|
||||
NVarTable.AddRow();
|
||||
NVarTable.SetCell("Variable", nvars[i][0]);
|
||||
NVarTable.SetCell("Type", nvars[i][1]);
|
||||
@@ -143,7 +145,8 @@ class CAdminMod : public CModule {
|
||||
{"Detached", boolean}
|
||||
};
|
||||
for (unsigned int i = 0; i != ARRAY_SIZE(cvars); ++i) {
|
||||
if (sVarFilter.empty() || sVarFilter.Equals(cvars[i][0], false, iVarLength)) {
|
||||
CString sVar = CString(cvars[i][0]).AsLower();
|
||||
if (sVarFilter.empty() || sVarFilter.Equals(sVar, true, iVarLength) || sVar.WildCmp(sVarFilter)) {
|
||||
CVarTable.AddRow();
|
||||
CVarTable.SetCell("Variable", cvars[i][0]);
|
||||
CVarTable.SetCell("Type", cvars[i][1]);
|
||||
|
||||
@@ -1549,7 +1549,7 @@ void CClient::UserPortCommand(CString& sLine) {
|
||||
static void AddCommandHelp(CTable& Table, const CString& sCmd, const CString& sArgs, const CString& sDesc, const CString& sFilter = "")
|
||||
{
|
||||
const CString::size_type iFilterLength = sFilter.size();
|
||||
if (sFilter.empty() || sCmd.Equals(sFilter, false, iFilterLength)) {
|
||||
if (sFilter.empty() || sCmd.Equals(sFilter, false, iFilterLength) || sCmd.AsLower().WildCmp(sFilter.AsLower())) {
|
||||
Table.AddRow();
|
||||
Table.SetCell("Command", sCmd);
|
||||
Table.SetCell("Arguments", sArgs);
|
||||
|
||||
+3
-2
@@ -570,14 +570,15 @@ bool CModule::HandleCommand(const CString& sLine) {
|
||||
}
|
||||
|
||||
void CModule::HandleHelpCommand(const CString& sLine) {
|
||||
CString sFilter = sLine.Token(1);
|
||||
CString sFilter = sLine.Token(1).AsLower();
|
||||
CString::size_type iFilterLength = sFilter.size();
|
||||
CTable Table;
|
||||
map<CString, CModCommand>::const_iterator it;
|
||||
|
||||
CModCommand::InitHelp(Table);
|
||||
for (it = m_mCommands.begin(); it != m_mCommands.end(); ++it) {
|
||||
if (sFilter.empty() || (it->second.GetCommand().Equals(sFilter, false, iFilterLength))) {
|
||||
CString sCmd = it->second.GetCommand().AsLower();
|
||||
if (sFilter.empty() || (sCmd.Equals(sFilter, true, iFilterLength)) || sCmd.WildCmp(sFilter)) {
|
||||
it->second.AddHelp(Table);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user