static void Main (string [] args) { Query query = new Query (); foreach (string arg in args) query.AddText (arg); SnippetReader snippet_reader; // FIXME: Oops ... does not quit by passing empty line snippet_reader = SnippetFu.GetSnippet (args, Console.In, false, -1, -1); //delegate { bool first = true; foreach (SnippetLine snippet_line in snippet_reader.GetSnippet ()) { Console.WriteLine ("\nSnippet:\n{0}", snippet_line.ToString ()); } }
public static void Main (string[] args) { // Initialize GObject type system g_type_init (); Beagrep.Util.Log.Level = LogLevel.Always; // shhhh... silence if (args.Length == 0 || Array.IndexOf (args, "--help") > -1 || Array.IndexOf (args, "--usage") > -1) PrintUsageAndExit (); if (Array.IndexOf (args, "--version") > -1) { VersionFu.PrintVersion (); Environment.Exit (0); } StringBuilder query_str = new StringBuilder (); query = new Query (); // Parse args int i = 0; string next_arg; while (i < args.Length) { switch (args [i]) { case "--verbose": verbose = true; break; case "--cache": display_cached_text = true; break; case "--stats-only": verbose = true; display_hits = false; break; case "--max-hits": if (++i >= args.Length) PrintUsageAndExit (); query.MaxHits = Int32.Parse (args[i]); break; case "--list-backends": Console.WriteLine ("Current available backends:"); Console.Write (QueryDriver.ListBackends ()); Environment.Exit (0); break; case "--backend": if (++i >= args.Length) PrintUsageAndExit (); next_arg = args [i]; if (next_arg.StartsWith ("--")) { Console.WriteLine ("--backend requires a backend name. Invalid name '{0}'", next_arg); Environment.Exit (1); break; } if (next_arg [0] != '+' && next_arg [0] != '-') QueryDriver.OnlyAllow (next_arg); else { if (next_arg [0] == '+') QueryDriver.Allow (next_arg.Substring (1)); else QueryDriver.Deny (next_arg.Substring (1)); } break; case "--add-static-backend": if (++i >= args.Length) PrintUsageAndExit (); next_arg = args [i]; if (! next_arg.StartsWith ("--")) QueryDriver.AddStaticQueryable (next_arg); break; case "--keywords": PropertyKeywordFu.ReadKeywordMappings (); Console.WriteLine ("Supported query keywords are:"); foreach (string key in PropertyKeywordFu.Keys) { foreach (QueryKeywordMapping mapping in PropertyKeywordFu.Properties (key)) { // Dont print properties without description; they confuse people if (string.IsNullOrEmpty (mapping.Description)) continue; Console.WriteLine (" {0,-20} for {1}", key, mapping.Description); } } System.Environment.Exit (0); break; default: if (args [i].StartsWith ("--")) PrintUsageAndExit (); if (query_str.Length > 0) query_str.Append (' '); query_str.Append (args [i]); break; } ++i; } if (verbose) Beagrep.Util.Log.Level = LogLevel.Debug; if (query_str.Length > 0) query.AddText (query_str.ToString ()); Stopwatch watch = new Stopwatch (); watch.Start (); StartQueryDriver (); watch.Stop (); if (verbose) Console.WriteLine ("QueryDriver started in {0}", watch); QueryResult result = new QueryResult (); result.HitsAddedEvent += OnHitsAdded; result.FinishedEvent += OnFinished; queryStartTime = DateTime.Now; QueryDriver.DoQueryLocal (query, result); }