4 // Lukas Lipka <lukas@pmad.net>
5 // Raphael Slinckx <rslinckx@gmail.com>
7 // Copyright (C) 2005 Novell, Inc.
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.
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
)
44 Catalog
.Init ("beagle", Beagle
.Util
.ExternalStringsHack
.LocaleDir
);
46 SystemInformation
.SetProcessName ("beagle-imlogviewer");
52 imclient
= (ImClient
) Enum
.Parse (typeof (ImClient
), client
, true);
54 Console
.WriteLine ("ERROR: '{0}' is not a valid client name.", client
);
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" +
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.");
73 private static void ParseArgs (string [] args
)
78 for (int i
= 0; i
< args
.Length
; i
++) {
85 case "--highlight-search":
86 highlight
= args
[i
+ 1];
91 search
= args
[i
+ 1];
96 client
= args
[i
+ 1];
101 if (args
[i
].StartsWith ("--")) {
102 Console
.WriteLine ("WARN: Invalid option {0}", args
[i
]);
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);