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
parent 3eaa308d28
commit 1f16d6dc32

View File

@@ -414,7 +414,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)
@@ -448,12 +448,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);
}