* We parse the specified schema and generate code accordingly.
* @param args The program arguments.
*/
public void run(String[] args) {
CommandLine cl = new CommandLine();
ResultSet rs = new ResultSet();
nameFormat = new PrintfFormat("%-30s");
numFormat = new PrintfFormat("%10d");
colFormat = new PrintfFormat("%10s");
longestName = 0;
packages = new TreeMap<String,TreeMap<String,CodeCountInfo>>();
out = null;
help = new StringBuffer();
// ***************************************************************************
help.append("count -h -workspace -id -of -r -skip\n\n");
help.append("The code count tool provides a simple code count mechansism. It indicates the\n");
help.append("number of source, comment, import and blank lines in a set of Java files\n");
help.append("and how many files are auto generated.\n");
help.append("\n");
help.append("-h Dumps the help information\n");
help.append("\n");
help.append("-workspace Indicates the workspace prefix.\n");
help.append("\n");
help.append("-id Indicates the directory beneath the workspace at which parsing should start. \n");
help.append("\n");
help.append("-of The output file name.\n");
help.append("\n");
help.append("-r Indicates that you want to recurse through all subdirectories. \n");
help.append("\n");
help.append("-skip (suffix) Indicates that you want to skip subdirectories that end with the \n");
help.append(" specified suffix.\n");
help.append("\n");
help.append("\n");
cl.addOption("-h",helpFlag,"Dumps the help message.");
cl.addOption("-o",ofn,"Output file name.");
cl.addOption("-workspace", workspace, "The workspace prefix");
cl.addOption("-indir",inDir,"The input directory");
cl.addOption("-of",outDir,"The output directory");
cl.addOption("-r",recursiveFlag,"Recurses through all subdirectories.");
cl.addOption("-skip",skip,"Skips the specified directory.");
cl.parseArgs(args);
if (ofn.length() > 0){
try {
out = new BufferedWriter(new FileWriter(ofn.toString()));
} catch (IOException e) {
System.out.println("IO Error:\n" + e);
System.exit(1);
}
}
// println("The args " + args[0] + "\n");
if ((args.length == 0) || helpFlag.booleanValue() == true){
println(help.toString());
System.exit(0);
}
if (workspace.length() == 0){
System.err.println("You must specify the -workspace argument");
System.exit(1);
}
String startDir = workspace.toString();
if (inDir.length() > 0){
startDir = startDir + File.separator + inDir.toString();
}
readDirectory(rs,startDir);
nameFormat = new PrintfFormat("%-" + longestName + "s");
totalFormat = new PrintfFormat("%" + longestName + "s");
dumpInfo();
println(rs.toString());
if (out != null){
try {
System.out.println("Output written to " + ofn.toString());
out.close();