01: /*
02: * Copyright 1999
03: *
04: * Chris Seguin
05: * All rights reserved
06: */
07: package org.acm.seguin.tools.builder;
08:
09: import java.util.Iterator;
10: import org.acm.seguin.metrics.*;
11: import org.acm.seguin.summary.PackageSummary;
12: import org.acm.seguin.summary.SummaryTraversal;
13: import org.acm.seguin.summary.load.LoadStatus;
14: import org.acm.seguin.summary.load.SilentLoadStatus;
15: import org.acm.seguin.summary.load.TextLoadStatus;
16: import org.acm.seguin.tools.RefactoryInstaller;
17: import org.acm.seguin.util.FileSettings;
18:
19: /**
20: * Gathers metrics data
21: *
22: *@author Chris Seguin
23: *@created July 25, 1999
24: */
25: public class Metrics {
26: /**
27: * Main program
28: *
29: *@param args the command line arguments
30: */
31: public static void main(String[] args) {
32: // Local Variables
33: String startDir = System.getProperty("user.dir");
34: int type = 0;
35: LoadStatus status = new TextLoadStatus();
36:
37: // Process command line arguments
38: int argIndex = 0;
39: while (argIndex < args.length) {
40: if (args[argIndex].equals("-help")) {
41: System.out
42: .println("Syntax: java Metrics [-text|-comma] [dir]");
43: return;
44: } else if (args[argIndex].equals("-text")) {
45: type = 0;
46: argIndex++;
47: } else if (args[argIndex].equals("-comma")) {
48: type = 1;
49: argIndex++;
50: } else if (args[argIndex].equals("-quiet")) {
51: status = new SilentLoadStatus();
52: argIndex++;
53: } else if (args[argIndex].equals("-config")) {
54: String dir = args[argIndex + 1];
55: argIndex++;
56: FileSettings.setSettingsRoot(dir);
57: } else {
58: startDir = args[argIndex];
59: argIndex++;
60: }
61: }
62:
63: // Make sure everything is installed properly
64: (new RefactoryInstaller(false)).run();
65:
66: // Gather the summary
67: (new SummaryTraversal(startDir, status)).run();
68:
69: // Now print everything
70: MetricsReport metricsReport;
71: if (type == 0) {
72: metricsReport = new TextReport();
73: } else {
74: metricsReport = new CommaDelimitedReport();
75: }
76: GatherData visitor = new GatherData(metricsReport);
77: ProjectMetrics projectData = (ProjectMetrics) visitor.visit("");
78:
79: metricsReport.finalReport(projectData);
80: }
81: }
|