Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 1f16d6dc32a80bfe14f92b64e14d42183a7f3acf 1 parent 3eaa308
Kyle Fuller kylef authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 Modules.cpp
11 Modules.cpp
View
@@ -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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.