X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;ds=sidebyside;f=Config.cs;h=a4332e1a798020b76607dec0b3990884c17d0f35;hb=11835c28c3407f9bbd4aa68b875a528d13ff0d73;hp=3ffd66d6845177903052210e2d11b4d1f22db18d;hpb=b244412c1fbb99111bf820bb72f5b6146174405f;p=WebThing.git diff --git a/Config.cs b/Config.cs index 3ffd66d..a4332e1 100644 --- a/Config.cs +++ b/Config.cs @@ -5,6 +5,16 @@ using System.Collections.Generic; using System.Text.RegularExpressions; namespace bytex64.WebThing { + public struct SearchHandlerPair { + public string Shortcut; + public string Plugin; + + public SearchHandlerPair(string s, string p) { + Shortcut = s; + Plugin = p; + } + } + public class Config { public static List ConfigPath; public static string ConfigPathOut = null; @@ -13,6 +23,7 @@ namespace bytex64.WebThing { public static Dictionary> PluginOptions; public static string[] Arguments; public static List Plugins; + public static List SearchHandlers; private static HashSet CommandLineOptions; private static Regex item_re = new Regex(@"^(?:([\w.]+)\.)?(\w+)$"); @@ -24,6 +35,7 @@ namespace bytex64.WebThing { PluginOptions = new Dictionary>(); CommandLineOptions = new HashSet(); Plugins = new List(); + SearchHandlers = new List(); // Set up ConfigPath IDictionary Env = Environment.GetEnvironmentVariables(); @@ -53,8 +65,7 @@ namespace bytex64.WebThing { PluginOptions[plugin] = new Dictionary(); PluginOptions[plugin][name] = val; } else { // Global Option - switch(key) { - case "Plugin": + switch(key.ToLower()) { case "plugin": Plugins.Add(val); break; @@ -169,12 +180,19 @@ namespace bytex64.WebThing { m = file_command_re.Match(line); if (m.Success) { - string cmd = m.Groups[1].Value; + string cmd = m.Groups[1].Value.ToLower(); switch(cmd) { - case "Plugin": case "plugin": Plugins.Add(m.Groups[2].Value); break; + case "searchhandler": + string[] args = Regex.Split(m.Groups[2].Value, @"\s+"); + if (args.Length != 2) { + Console.WriteLine("Expecting two arguments for SearchHandler."); + break; + } + SearchHandlers.Add(new SearchHandlerPair(args[0], args[1])); + break; default: Console.WriteLine("Unknown Command in {0}: {1}", filename, line); break;