List of usage examples for org.apache.commons.cli ParseException getStackTrace
public StackTraceElement[] getStackTrace()
From source file:com.github.sgelb.sldownloader.SLDownloader.java
public void runCLI(String[] args) { // get command line options Options options = new Options(); options.addOption("g", "gui", false, "start GUI"); options.addOption("u", "url", true, "Url"); options.addOption("o", "output", true, "save folder [default: $home]"); CommandLineParser parser = new BasicParser(); if (args.length == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("SLDownloader", options, true); return;//from w w w. j a va 2 s . co m } CommandLine cmdline = null; try { cmdline = parser.parse(options, args); } catch (org.apache.commons.cli.ParseException e) { e.printStackTrace(); } if (cmdline.hasOption("g")) { runGUI(); return; } String url = null; if (cmdline.hasOption("u") && RegEx.matchUrl(cmdline.getOptionValue("u"))) { url = cmdline.getOptionValue("u"); } else { System.out.println("Please use a valid url"); System.exit(-1); } File saveFolder = new File(System.getProperty("user.home")); if (cmdline.getOptionValue("o") != null) { File tmpFile = new File(cmdline.getOptionValue("o")); if (tmpFile.isDirectory()) { saveFolder = new File(cmdline.getOptionValue("o")); } } System.out.println("Download " + url); System.out.println("Save to " + saveFolder); Book book = new Book(); Parser parsePage = new Parser(url, book); try { parsePage.parseHtml(); } catch (NoAccessException e) { System.out.println("You don't have access to this book."); System.exit(-1); } catch (HttpStatusException e) { System.out.println("Error " + e.getStatusCode()); System.exit(-1); } catch (IOException e) { System.out.println("Error: " + e.getStackTrace()); System.exit(-1); } parsePage.setBookData(); Pdf pdf = null; try { pdf = new Pdf(book, saveFolder); pdf.downloadAll(); pdf.mergePdfs(); } catch (IOException | DocumentException e) { e.printStackTrace(); } }
From source file:uk.ac.tgac.citadel.CitadelCLI.java
/** * The main entry point for Citadel./*from www .j a v a 2s.c o m*/ * @param args Command line arguments * @throws java.io.IOException Thrown if there was an error printing the help message */ public static void main(String[] args) throws IOException { try { CitadelCLI citadelCLI = new CitadelCLI(args); StopWatch stopwatch = new StopWatch(); stopwatch.start(); if (citadelCLI == null) throw new IllegalArgumentException("Invalid arguments, could not create a valid citadel object."); if (citadelCLI.isHelp()) { citadelCLI.printHelp(); } else if (citadelCLI.version) { System.out.println("Version: " + loadVersion()); } else { citadelCLI.initialise(); citadelCLI.execute(); stopwatch.stop(); System.out.println("Total runtime (wall clock): " + stopwatch.toString()); } } catch (ParseException e) { System.err.println("\n" + e.getMessage() + "\n"); new CitadelCLI().printHelp(); System.exit(1); } catch (Exception e) { System.err.println(e.getMessage()); System.err.println(StringUtils.join(e.getStackTrace(), "\n")); System.exit(2); } }
From source file:uk.ac.tgac.jellyswarm.JellyswarmCLI.java
public static void main(String[] args) throws IOException { try {/*from w ww. j a v a2 s.c o m*/ // Create new app and parse args JellyswarmCLI jellyswarm = new JellyswarmCLI(args); if (jellyswarm == null) throw new IllegalArgumentException( "Invalid arguments, could not create a valid jellyswarm object."); if (jellyswarm.isHelp() || args.length == 0) { jellyswarm.printHelp(); } else if (jellyswarm.version) { System.out.println("Version: " + loadVersion()); } else { jellyswarm.execute(); } } catch (ParseException e) { System.err.println("\n" + e.getMessage() + "\n"); new JellyswarmCLI().printHelp(); System.exit(1); } catch (Exception e) { System.err.println(e.getMessage()); System.err.println(StringUtils.join(e.getStackTrace(), "\n")); System.exit(2); } }
From source file:uk.ac.tgac.rampart.RampartCLI.java
/** * The main entry point for RAMPART. Looks at the first argument to decide which mode to run in. Execution of each * mode is handled by RampartMode.//from ww w . jav a 2 s. com * @param args Command line arguments * @throws IOException Thrown if there was an error printing the help message */ public static void main(String[] args) throws IOException { try { RampartCLI rampartCLI = new RampartCLI(args); StopWatch stopwatch = new StopWatch(); stopwatch.start(); if (rampartCLI == null) throw new IllegalArgumentException("Invalid arguments, could not create a valid rampart object."); if (rampartCLI.isHelp()) { rampartCLI.printHelp(); } else if (rampartCLI.version) { System.out.println("Version: " + loadVersion()); } else { rampartCLI.initialise(); rampartCLI.execute(); stopwatch.stop(); System.out.println("Total runtime (wall clock): " + stopwatch.toString()); } } catch (ParseException e) { System.err.println("\n" + e.getMessage() + "\n"); new RampartCLI().printHelp(); System.exit(1); } catch (Exception e) { System.err.println(e.getMessage()); System.err.println(StringUtils.join(e.getStackTrace(), "\n")); System.exit(2); } }