1 package net.firstpartners.nounit.ui.command; 2 3 26 27 import org.apache.log4j.Logger; 28 29 import net.firstpartners.nounit.ui.common.*; 30 import net.firstpartners.nounit.utility.*; 31 32 39 public class CommandLineProcessor { 40 41 static Logger log = Logger.getLogger(CommandLineProcessor.class); 43 44 49 public static void main(String [] args) 50 throws NoUnitException { 51 52 log.debug(""); 54 CommandPackage userArgs; 56 CommandPackage results; 57 Processor mainProcessor = new Processor(); 58 59 if (args.length==0) { 61 log.debug(getInstructions()); 62 return; 63 } else { 64 65 try{ 66 67 checkArgsLength(args.length); 69 70 userArgs = new CommandPackage(args); 72 73 results = mainProcessor.transform(userArgs); 75 76 log.debug(results.getString(CommandPackage.USER_MESSAGE)); 78 79 } catch (NoUnitException nue) { 80 81 nue.printStackTrace(); 83 log.debug("----------------"); 84 Exception e = nue.getOriginalException(); 85 if (e!=null) { 86 e.printStackTrace(); 87 } 88 } 89 } 90 } 91 92 96 private static String getInstructions(){ 97 98 StringBuffer instructions = new StringBuffer (); 99 100 instructions.append("\n\n"); 101 instructions.append("NoUnit Test Coverage Measure\n"); 102 instructions.append("============================\n"); 103 instructions.append("\n"); 104 instructions.append("Parameters: (*) marks optional\n"); 105 instructions.append("\n"); 106 instructions.append("start_dir (directory to start looking for java files)\n"); 107 instructions.append("output_dir (directory to output to)\n"); 108 instructions.append("report_class (Class to Generate NoUnit Report)\n"); 109 110 111 112 return instructions.toString(); 113 114 } 115 116 121 private static void checkArgsLength(int argsLength) 122 throws NoUnitException { 123 124 int a; 126 127 for (a=argsLength;a>1;a=a-2) { 128 129 } 131 132 if (a!=0) { 134 throw new NoUnitException("Please supply an even number of parameters (i.e. key-name key-value)"); 136 137 } 138 139 } 140 141 } | Popular Tags |