Process arguments and set up member fields appropriately. Will shut down the process (via System.exit) if there are incorrect arguments, or if the arguments ask for something simple like printing the help message.
(String[] args)
| 338 | * simple like printing the help message. |
| 339 | */ |
| 340 | public static void processArgs(String[] args) { |
| 341 | |
| 342 | Getopt g = new Getopt("GATE main", args, "hd:ei:"); |
| 343 | int c; |
| 344 | while( (c = g.getopt()) != -1 ) |
| 345 | switch(c) { |
| 346 | // -h |
| 347 | case 'h': |
| 348 | help(); |
| 349 | usage(); |
| 350 | System.exit(STATUS_NORMAL); |
| 351 | break; |
| 352 | // -d creole-dir |
| 353 | case 'd': |
| 354 | String urlString = g.getOptarg(); |
| 355 | URL u = null; |
| 356 | try { |
| 357 | u = new URL(urlString); |
| 358 | } catch(MalformedURLException e) { |
| 359 | Err.prln("Bad URL: " + urlString); |
| 360 | Err.prln(e); |
| 361 | System.exit(STATUS_ERROR); |
| 362 | } |
| 363 | pendingCreoleUrls.add(u); |
| 364 | Out.prln( |
| 365 | "CREOLE Directory " + urlString + " queued for registration" |
| 366 | ); |
| 367 | break; |
| 368 | // -i gate.xml site-wide init file |
| 369 | case 'i': |
| 370 | String optionString = g.getOptarg(); |
| 371 | @SuppressWarnings("unused") |
| 372 | URL u2 = null; |
| 373 | File f = new File(optionString); |
| 374 | try { |
| 375 | u2 = f.toURI().toURL(); |
| 376 | } catch(MalformedURLException e) { |
| 377 | Err.prln("Bad initialisation file: " + optionString); |
| 378 | Err.prln(e); |
| 379 | System.exit(STATUS_ERROR); |
| 380 | } |
| 381 | Gate.setSiteConfigFile(f); |
| 382 | if(DEBUG) |
| 383 | Out.prln( |
| 384 | "Initialisation file " + optionString + |
| 385 | " recorded for initialisation" |
| 386 | ); |
| 387 | break; |
| 388 | case '?': |
| 389 | // leave the warning to getopt |
| 390 | System.exit(STATUS_ERROR); |
| 391 | break; |
| 392 | |
| 393 | default: |
| 394 | // shouldn't happen! |
| 395 | Err.prln("getopt() returned " + c + "\n"); |
| 396 | System.exit(STATUS_ERROR); |
| 397 | break; |