From 30e8b0303863c9c720b7cd8964205e1b56e96740 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 30 Jan 2010 13:34:25 -0500 Subject: [PATCH] Enhancements - Hooks - The config command now reports missing or unreadable hook scripts. --- src/command.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/command.cpp b/src/command.cpp index 6103baea1..0e3cfa8ea 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -38,6 +38,7 @@ #include "Permission.h" #include "Directory.h" +#include "Nibbler.h" #include "text.h" #include "util.h" #include "main.h" @@ -720,7 +721,48 @@ int handleConfig (std::string &outs) out << context.config.checkForDeprecatedColor (); // TODO Check for referenced but missing theme files. // TODO Check for referenced but missing string files. - // TODO Check for referenced but missing hook scripts. + // TODO Check for referenced but missing tips files. + + // Check for referenced but missing hook scripts. +#ifdef HAVE_LIBLUA + std::vector missing_scripts; + foreach (i, all) + { + if (i->substr (0, 5) == "hook.") + { + std::string value = context.config.get (*i); + Nibbler n (value); + + // : [, ...] + while (!n.depleted ()) + { + std::string file; + std::string function; + if (n.getUntil (':', file) && + n.skip (':') && + n.getUntil (',', function)) + { + Path script (file); + if (!script.exists () || !script.readable ()) + missing_scripts.push_back (file); + + (void) n.skip (','); + } + } + } + } + + if (missing_scripts.size ()) + { + out << "Your .taskrc file contains these missing or unreadable hook scripts:" + << std::endl; + + foreach (i, missing_scripts) + out << " " << *i << std::endl; + + out << std::endl; + } +#endif // Check for bad values in rc.annotations. std::string annotations = context.config.get ("annotations");