0 == cline.getArgs().length) {
List<String> names = argToStringList(cline.getOptionValue(DECOMPILE_OPTION));
List<File> classpath = argToFileList(cline.getOptionValue(CLASSPATH_OPTION));
File dir = new File(cline.getOptionValue(OUTPUT_OPTION));
System.out.println("Initializing decompiler ...");
new KrakatauLibrary().decompile(classpath, names, dir);
} else if (cline.hasOption(DISASSEMBLE_OPTION) &&
cline.hasOption(OUTPUT_OPTION) &&
0 == cline.getArgs().length) {
List<File> files = argToFileList(cline.getOptionValue(DISASSEMBLE_OPTION));
File dir = new File(cline.getOptionValue(OUTPUT_OPTION));
System.out.println("Initializing disassembler ...");
new KrakatauLibrary().disassemble(files, dir);
} else if (cline.hasOption(ASSEMBLE_OPTION) &&
cline.hasOption(OUTPUT_OPTION) &&
0 == cline.getArgs().length) {
List<File> files = argToFileList(cline.getOptionValue(ASSEMBLE_OPTION));
File dir = new File(cline.getOptionValue(OUTPUT_OPTION));
System.out.println("Initializing assembler ...");
new KrakatauLibrary().assemble(files, dir);
} else if(cline.hasOption(COMPILE_OPTION) &&
cline.hasOption(OUTPUT_OPTION) &&
0 == cline.getArgs().length) {
System.out.println("Initializing compiler ...");
List<File> sources = argToFileList(cline.getOptionValue(COMPILE_OPTION));
List<File> classpath = cline.hasOption(CLASSPATH_OPTION) ?
argToFileList(cline.getOptionValue(CLASSPATH_OPTION)) :
Collections.<File>emptyList();
File dir = new File(cline.getOptionValue(OUTPUT_OPTION));
new KrakatauLibrary().compile(sources, classpath, dir, new OutputStreamWriter(System.err));
System.out.println("Compilation complete");
} else {
throw new ParseException("Invalid arguments:");
}
} catch (ParseException e) {