Skip to content

Commit

Permalink
Let a user filter the result of help CModule::HandleHelpCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
kylef authored and psychon committed Jan 1, 2012
1 parent 7474c43 commit 39f97a8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Modules.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 39f97a8

Please sign in to comment.