mirror of
https://github.com/znc/znc.git
synced 2026-07-03 00:11:59 +02:00
Merge pull request #669 from jpnurmi/help
Allow wildcards in help command args
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]);
|
||||
@@ -119,7 +120,8 @@ class CAdminMod : public CModule {
|
||||
{"QuitMsg", str},
|
||||
};
|
||||
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]);
|
||||
@@ -144,7 +146,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);
|
||||
@@ -1652,5 +1652,9 @@ void CClient::HelpUser(const CString& sFilter) {
|
||||
AddCommandHelp(Table, "Restart", "[message]", "Restart ZNC", sFilter);
|
||||
}
|
||||
|
||||
PutStatus(Table);
|
||||
if (Table.empty()) {
|
||||
PutStatus("No matches for '" + sFilter + "'");
|
||||
} else {
|
||||
PutStatus(Table);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -570,18 +570,23 @@ 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);
|
||||
}
|
||||
}
|
||||
PutModule(Table);
|
||||
if (Table.empty()) {
|
||||
PutModule("No matches for '" + sFilter + "'");
|
||||
} else {
|
||||
PutModule(Table);
|
||||
}
|
||||
}
|
||||
|
||||
CString CModule::GetModNick() const { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; }
|
||||
|
||||
Reference in New Issue
Block a user