Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / ImLogViewer / ImLogViewer.cs
blobb620563799d63fe55b958023be78fda8ee72cf73
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 //
10 using System;
11 using Mono.Posix;
13 namespace ImLogViewer {
15 public class ImLogViewer {
17 private static string highlight;
18 private static string search;
19 private static string path;
21 public static void Main (string[] args)
23 // I18N
24 Catalog.Init ("beagle", Beagle.Util.ExternalStringsHack.LocaleDir);
26 ParseArgs (args);
27 ImLogWindow window = new ImLogWindow (path, search, highlight);
30 private static void PrintUsageAndExit ()
32 Console.WriteLine ("USAGE: beagle-imlogviewer [OPTIONS] <log file or directory>\n" +
33 "Options:\n" +
34 " --highlight-search\t\tWords to highlight in the buffer.\n" +
35 " --search\t\t\tSearch query to filter hits on.");
37 Environment.Exit (0);
40 private static void ParseArgs (string [] args)
42 if (args.Length < 1)
43 PrintUsageAndExit ();
45 for (int i = 0; i < args.Length; i++) {
46 switch (args [i]) {
47 case "-h":
48 case "--help":
49 PrintUsageAndExit ();
50 break;
52 case "--highlight-search":
53 highlight = args [i + 1];
54 i++;
55 break;
57 case "--search":
58 search = args [i + 1];
59 i++;
60 break;
62 default:
63 if (args [i].StartsWith ("--")) {
64 Console.WriteLine ("WARN: Invalid option {0}", args [i]);
65 } else {
66 path = args [i];
68 break;
72 if (path == null) {
73 Console.WriteLine ("ERROR: Please specify a valid log path or log directory.");
74 Environment.Exit (1);