use of org.apache.commons.cli.DefaultParser in project tika by apache.
the class FSBatchProcessCLI method execute.
private void execute(String[] args) throws Exception {
CommandLineParser cliParser = new DefaultParser();
CommandLine line = cliParser.parse(options, args);
if (line.hasOption("help")) {
usage();
System.exit(BatchProcessDriverCLI.PROCESS_NO_RESTART_EXIT_CODE);
}
Map<String, String> mapArgs = new HashMap<String, String>();
for (Option option : line.getOptions()) {
String v = option.getValue();
if (v == null || v.equals("")) {
v = "true";
}
mapArgs.put(option.getOpt(), v);
}
BatchProcessBuilder b = new BatchProcessBuilder();
TikaInputStream is = null;
BatchProcess process = null;
try {
is = getConfigInputStream(args, false);
process = b.build(is, mapArgs);
} finally {
IOUtils.closeQuietly(is);
}
final Thread mainThread = Thread.currentThread();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<ParallelFileProcessingResult> futureResult = executor.submit(process);
ParallelFileProcessingResult result = futureResult.get();
System.out.println(FINISHED_STRING);
System.out.println("\n");
System.out.println(result.toString());
System.exit(result.getExitStatus());
}
Aggregations