From 77bb66419769e3fa357bdecee690dd4173069f0d Mon Sep 17 00:00:00 2001
From: Robert McLay <mclay@zaniahgroup.com>
Date: Sun, 24 Nov 2024 16:35:41 -0600
Subject: [PATCH] Issue #736: add help message to keyword search

---
 rt/keyword/err.txt       | 20 +++++++++++++++++++-
 rt/keyword/keyword.tdesc |  2 ++
 rt/keyword/out.txt       | 16 ++++++++++++++++
 src/Spider.lua           |  3 ++-
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/rt/keyword/err.txt b/rt/keyword/err.txt
index 70701b17f..3749ac1f8 100644
--- a/rt/keyword/err.txt
+++ b/rt/keyword/err.txt
@@ -2,7 +2,7 @@
 step 1
 lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
 ===========================
-Modules based on Lua: Version 8.7.16  2023-01-09 21:47 -06:00
+Modules based on Lua: Version 8.7.53 2024-10-12 19:57 -05:00
     by Robert McLay mclay@tacc.utexas.edu
 ===========================
 step 2
@@ -24,3 +24,21 @@ lua ProjectDIR/src/lmod.in.lua shell --regression_testing --terse keyword graph
 parmetis/
 parmetis/3.1
 parmetis/4.0.1
+===========================
+step 4
+lua ProjectDIR/src/lmod.in.lua shell --regression_testing keyword ICC_DIR
+===========================
+The following modules match your search criteria: "ICC_DIR"
+  intel: intel/intel
+To learn more about a package execute:
+   $ module spider Foo
+where "Foo" is the name of a module.
+To find detailed information about a particular package you
+must specify the version if there is more than one version:
+   $ module spider Foo/11.1
+===========================
+step 5
+lua ProjectDIR/src/lmod.in.lua shell --regression_testing --terse keyword ICC_DIR
+===========================
+intel/
+intel/intel
diff --git a/rt/keyword/keyword.tdesc b/rt/keyword/keyword.tdesc
index 1be21c20e..f94673f79 100644
--- a/rt/keyword/keyword.tdesc
+++ b/rt/keyword/keyword.tdesc
@@ -29,6 +29,8 @@ testdescript = {
      runLmod --version                  # 1
      runLmod           keyword graph    # 2
      runLmod --terse   keyword graph    # 3
+     runLmod           keyword ICC_DIR  # 4
+     runLmod --terse   keyword ICC_DIR  # 5
 
      HOME=$ORIG_HOME
 
diff --git a/rt/keyword/out.txt b/rt/keyword/out.txt
index 8c10f6791..ebe7542ac 100644
--- a/rt/keyword/out.txt
+++ b/rt/keyword/out.txt
@@ -20,3 +20,19 @@ MODULEPATH=ProjectDIR/rt/keyword/mf/Core;
 export MODULEPATH;
 _ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/keyword/mf/Core",},systemBaseMPATH="ProjectDIR/rt/keyword/mf/Core",}';
 export _ModuleTable_;
+===========================
+step 4
+lua ProjectDIR/src/lmod.in.lua shell --regression_testing keyword ICC_DIR
+===========================
+MODULEPATH=ProjectDIR/rt/keyword/mf/Core;
+export MODULEPATH;
+_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/keyword/mf/Core",},systemBaseMPATH="ProjectDIR/rt/keyword/mf/Core",}';
+export _ModuleTable_;
+===========================
+step 5
+lua ProjectDIR/src/lmod.in.lua shell --regression_testing --terse keyword ICC_DIR
+===========================
+MODULEPATH=ProjectDIR/rt/keyword/mf/Core;
+export MODULEPATH;
+_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/keyword/mf/Core",},systemBaseMPATH="ProjectDIR/rt/keyword/mf/Core",}';
+export _ModuleTable_;
diff --git a/src/Spider.lua b/src/Spider.lua
index d15f03bd9..bf6a52a3a 100644
--- a/src/Spider.lua
+++ b/src/Spider.lua
@@ -246,9 +246,10 @@ function M.searchSpiderDB(self, strA, dbT, providedByT)
       for fn, vv in pairs(vvv) do
          local whatisS  = concatTbl(vv.whatis or {},"\n"):lower()
          local found    = false
+         local help     = vv.help or ""
          for i = 1,strA.n do
             local str = strA[i]
-            if (sn:find(str) or whatisS:find(str)) then
+            if (sn:find(str) or whatisS:find(str) or help:find(str)) then
                found = true
                break
             end