Let a user filter the result of help CModule::HandleHelpCommand

This commit is contained in:
Kyle Fuller
2011-08-31 14:00:00 +01:00
committed by Uli Schlachter
parent 7474c43902
commit 39f97a887d
+8 -3
View File
@@ -411,7 +411,7 @@ bool CModule::AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func, cons
void CModule::AddHelpCommand()
{
AddCommand("Help", &CModule::HandleHelpCommand, "", "Generate this output");
AddCommand("Help", &CModule::HandleHelpCommand, "search", "Generate this output");
}
bool CModule::RemCommand(const CString& sCmd)
@@ -445,12 +445,17 @@ bool CModule::HandleCommand(const CString& sLine) {
}
void CModule::HandleHelpCommand(const CString& sLine) {
CString sFilter = sLine.Token(1, true);
unsigned int iFilterLength = sFilter.size();
CTable Table;
map<CString, CModCommand>::const_iterator it;
CModCommand::InitHelp(Table);
for (it = m_mCommands.begin(); it != m_mCommands.end(); ++it)
it->second.AddHelp(Table);
for (it = m_mCommands.begin(); it != m_mCommands.end(); ++it) {
if (sFilter.empty() || (it->second.GetCommand().Equals(sFilter, false, iFilterLength))) {
it->second.AddHelp(Table);
}
}
PutModule(Table);
}