1   package intellego;
2   
3   import main.*;
4   import util.*;
5   
6   /**
7   * Startup class - starts the whole system
8   */
9   public class Intellego
10  {
11      private static boolean debugMode;   // debug mode flag
12      private static IntellegoLog log;    // the log for this run
13      
14      /**
15      * Adds a message to the log
16      *
17      * @param message the message to be added
18      */
19      public static void addToLog(String message)
20      {
21          // if we're in debug mode, print the messages out to the scren as well
22          if(debugMode)
23          {
24              System.out.println("Log message: "+message);
25          }
26          
27          // add the message to the log
28          log.addMessage(message);
29      }
30      
31      /**
32      * Prints usage instructions to stdout
33      */
34      public static void printUsage()
35      {
36          System.out.println( "\nUsage: java Intellego [-option]\n"+
37                              "\nwhere option is one of:\n\n"+
38                              "\t-d -debug\truns Intellego in debug mode (prints messages to stdout)\n"+
39                              "\t-h -help\tdisplays this message");
40      }
41      
42      /**
43      * Fires up the whole system
44      */
45      public static void main(String args[])
46      {
47          // set debug mode
48          debugMode=false;
49          
50          // check command line args
51          if (args.length==0)
52          {
53              // do nothing
54          }
55          else if (args.length==1)
56          {
57              if (args[0].equalsIgnoreCase("-d") || args[0].equalsIgnoreCase("-debug"))
58              {
59                  debugMode=true;
60              }
61              else if (args[0].equalsIgnoreCase("-h") || args[0].equalsIgnoreCase("-help"))
62              {
63                  printUsage();
64                  System.exit(0);
65              }
66              else
67              {
68                  printUsage();
69                  System.exit(0);
70              }
71          }
72          else // unknown args
73          {
74              printUsage();
75              System.exit(0);
76          }
77          
78          // set up the log
79          log=new IntellegoLog();
80          
81          // fire up the main GUI
82          MainInterface gui=new MainInterface();
83          gui.setVisible(true);
84          
85          addToLog("Intellego.main(): GUI set up successfully");
86      }
87  }
88