From 1f16d6dc32a80bfe14f92b64e14d42183a7f3acf Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Wed, 31 Aug 2011 14:00:00 +0100 Subject: [PATCH] Let a user filter the result of help CModule::HandleHelpCommand --- Modules.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Modules.cpp b/Modules.cpp index f4fa81a2..7d22fb5f 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -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::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); }