KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > pth > Main


1 package polyglot.pth;
2
3 import java.io.PrintStream JavaDoc;
4 import java.util.*;
5
6 /**
7  *
8  */

9 public class Main {
10     public static void main(String JavaDoc[] args) {
11         new Main().start(args);
12     }
13     
14     public static Options options;
15      
16     public void start(String JavaDoc[] args) {
17         options = new Options();
18         try {
19             options.parseCommandLine(args);
20         }
21         catch (IllegalArgumentException JavaDoc e) {
22             System.err.println(e.getMessage());
23             System.exit(1);
24         }
25             
26         if (options.inputFilenames.isEmpty()) {
27             System.err.println("Need at least one script file.");
28             System.exit(1);
29         }
30         
31         OutputController outCtrl = createOutputController(options);
32         
33         for (Iterator iter = options.inputFilenames.iterator(); iter.hasNext(); ) {
34             String JavaDoc filename = (String JavaDoc)iter.next();
35             ScriptTestSuite t = new ScriptTestSuite(filename);
36             t.setOutputController(outCtrl);
37             if (options.showResultsOnly) {
38                 outCtrl.displayTestSuiteResults(t.getName(), t);
39             }
40             else {
41                 t.run();
42             }
43         }
44     }
45     
46     protected OutputController createOutputController(Options options) {
47         switch (options.verbosity) {
48             // More output controllers should be written, for varying degrees
49
// of detail.
50
case 0:
51                 return new SilentOutputController(System.out);
52             case 1:
53                 return new QuietOutputController(System.out, false, true, false, false, false);
54             case 2:
55                 return new QuietOutputController(System.out, false, true, false, false, true);
56             case 3:
57                 return new QuietOutputController(System.out, true, true, false, false, true);
58             case 8:
59                 return new VerboseOutputController(System.out, false);
60             case 9:
61                 return new VerboseOutputController(System.out, true);
62
63             default:
64                 return new StdOutputController(System.out);
65         }
66     }
67     
68 }
Popular Tags