public List<String> parseArgs(String[] args) { List<String> restArgs = super.parseArgs(args); List<String> remainingArgs = new ArrayList<String>(); for (int i = 0; i < restArgs.size(); i++) { String arg = restArgs.get(i); if (arg.equals("-prolog")) { // nothing to do } else if (arg.equals("-d")) { i++; if (i == restArgs.size()) { System.err.println("Please provide a destination directory"); System.exit(1); } else { destDir = new File(args[i]); } } else if (arg.equals("-fn")) { i++; if (i == restArgs.size()) { System.err.println("Please provide a file name"); System.exit(1); } else { outFilename = args[i]; } } else { remainingArgs.add(arg); } } return remainingArgs; }
private void initOutStreamEtc() throws Exception { if (!destDir.exists()) { System.err.println("Destination directory " + destDir.getAbsolutePath() + " does not exist!"); System.exit(1); } if (!destDir.canWrite()) { System.err.println( "Destination directory " + destDir.getAbsolutePath() + " cannot be written to!"); System.exit(1); } if (verbose) printAST(model, 0); outFile = new File(destDir, outFilename); // destDir and outFilename are initialized either in the constructor or in parseArgs, // which is called from parse outStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outFile))); }