QueryResponses.cs, DumpIndex.cs, IQueryResult.cs, QueryExecutor.cs, QueryResult.cs...
[beagle.git] / ImLogViewer / ImLogViewer.cs
bloba8cf8506fbf02f4874cf8ad9a2f28abec6c020a9
1 //
2 // ImLogViewer.cs
3 //
4 // Lukas Lipka <lukas@pmad.net>
5 // Raphael Slinckx <rslinckx@gmail.com>
6 //
7 // Copyright (C) 2005 Novell, Inc.
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a
10 // copy of this software and associated documentation files (the "Software"),
11 // to deal in the Software without restriction, including without limitation
12 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 // and/or sell copies of the Software, and to permit persons to whom the
14 // Software is furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
28 using System;
29 using Mono.Unix;
30 using Beagle.Util;
32 namespace ImLogViewer {
34 public class ImLogViewer {
36 private static string highlight;
37 private static string search;
38 private static string path;
39 private static string client;
41 public static void Main (string[] args)
43 // I18N
44 Catalog.Init ("beagle", Beagle.Util.ExternalStringsHack.LocaleDir);
46 SystemInformation.SetProcessName ("beagle-imlogviewer");
48 ParseArgs (args);
50 ImClient imclient;
51 try {
52 imclient = (ImClient) Enum.Parse (typeof (ImClient), client, true);
53 } catch (Exception) {
54 Console.WriteLine ("ERROR: '{0}' is not a valid client name.", client);
55 Environment.Exit (3);
56 return;
59 new ImLogWindow (imclient, path, search, highlight);
62 private static void PrintUsageAndExit ()
64 Console.WriteLine ("USAGE: beagle-imlogviewer --client <CLIENT> [OPTIONS] <log file or directory>\n" +
65 "Options:\n" +
66 " --client\t\t\tClient that the log belongs to (e.g. gaim).\n" +
67 " --highlight-search\t\tWords to highlight in the buffer.\n" +
68 " --search\t\t\tSearch query to filter hits on.");
70 Environment.Exit (0);
73 private static void ParseArgs (string [] args)
75 if (args.Length < 1)
76 PrintUsageAndExit ();
78 for (int i = 0; i < args.Length; i++) {
79 switch (args [i]) {
80 case "-h":
81 case "--help":
82 PrintUsageAndExit ();
83 break;
85 case "--highlight-search":
86 highlight = args [i + 1];
87 i++;
88 break;
90 case "--search":
91 search = args [i + 1];
92 i++;
93 break;
95 case "--client":
96 client = args [i + 1];
97 i++;
98 break;
100 default:
101 if (args [i].StartsWith ("--")) {
102 Console.WriteLine ("WARN: Invalid option {0}", args [i]);
103 } else {
104 path = args [i];
106 break;
110 if (path == null) {
111 Console.WriteLine ("ERROR: Please specify a valid log path or log directory.");
112 Environment.Exit (1);
115 if (client == null) {
116 Console.WriteLine ("ERROR: Please specify a valid client name.");
117 Environment.Exit (2);