()
| 220 | } |
| 221 | |
| 222 | protected void handleArgs() { |
| 223 | int i=0; |
| 224 | while ( args!=null && i<args.length ) { |
| 225 | String arg = args[i]; |
| 226 | i++; |
| 227 | if ( arg.startsWith("-D") ) { // -Dlanguage=Java syntax |
| 228 | handleOptionSetArg(arg); |
| 229 | continue; |
| 230 | } |
| 231 | if ( arg.charAt(0)!='-' ) { // file name |
| 232 | if ( !grammarFiles.contains(arg) ) grammarFiles.add(arg); |
| 233 | continue; |
| 234 | } |
| 235 | boolean found = false; |
| 236 | for (Option o : optionDefs) { |
| 237 | if ( arg.equals(o.name) ) { |
| 238 | found = true; |
| 239 | String argValue = null; |
| 240 | if ( o.argType==OptionArgType.STRING ) { |
| 241 | argValue = args[i]; |
| 242 | i++; |
| 243 | } |
| 244 | // use reflection to set field |
| 245 | Class<? extends Tool> c = this.getClass(); |
| 246 | try { |
| 247 | Field f = c.getField(o.fieldName); |
| 248 | if ( argValue==null ) { |
| 249 | if ( arg.startsWith("-no-") ) f.setBoolean(this, false); |
| 250 | else f.setBoolean(this, true); |
| 251 | } |
| 252 | else f.set(this, argValue); |
| 253 | } |
| 254 | catch (Exception e) { |
| 255 | errMgr.toolError(ErrorType.INTERNAL_ERROR, "can't access field "+o.fieldName); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | if ( !found ) { |
| 260 | errMgr.toolError(ErrorType.INVALID_CMDLINE_ARG, arg); |
| 261 | } |
| 262 | } |
| 263 | if ( outputDirectory!=null ) { |
| 264 | if (outputDirectory.endsWith("/") || |
| 265 | outputDirectory.endsWith("\\")) { |
| 266 | outputDirectory = |
| 267 | outputDirectory.substring(0, outputDirectory.length() - 1); |
| 268 | } |
| 269 | File outDir = new File(outputDirectory); |
| 270 | haveOutputDir = true; |
| 271 | if (outDir.exists() && !outDir.isDirectory()) { |
| 272 | errMgr.toolError(ErrorType.OUTPUT_DIR_IS_FILE, outputDirectory); |
| 273 | libDirectory = "."; |
| 274 | } |
| 275 | } |
| 276 | else { |
| 277 | outputDirectory = "."; |
| 278 | } |
| 279 | if ( libDirectory!=null ) { |
no test coverage detected