+ continue;
+ }
+
+ m = file_command_re.Match(line);
+ if (m.Success) {
+ string cmd = m.Groups[1].Value.ToLower();
+ switch(cmd) {
+ 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;
+ case "defaultsearchhandler":
+ DefaultSearchHandler = m.Groups[2].Value;
+ break;
+ default:
+ Console.WriteLine("Unknown Command in {0}: {1}", filename, line);
+ break;
+ }
+ continue;
+ }
+ }
+
+ f.Close();
+ }
+
+ public static void SaveFile(string filename) {
+ TextWriter f;
+ try {
+ f = new StreamWriter(filename);
+ } catch (IOException) {
+ Console.WriteLine("Could not save configuration to {0}", filename);
+ return;
+ }
+
+ foreach (string key in Options.Keys) {
+ if (CommandLineOptions.Contains(key)) continue;
+ f.WriteLine("{0} = {1}", key, Options[key]);
+ }
+
+ foreach (string plugin in PluginOptions.Keys) {
+ foreach (string key in PluginOptions[plugin].Keys) {
+ string pkey = String.Format("{0}.{1}", plugin, key);
+ if (CommandLineOptions.Contains(pkey)) continue;
+ f.WriteLine("{0} = {1}", pkey, PluginOptions[plugin][key]);