This page is the online appendix for the paper entitled: "Recommending API Function Calls and Code Snippets to Support Software Development" submitted to the IEEE Transactions on Software Engineering. We introduce additional code examples recommended by FOCUS
public static void getSiteImages() throws IOException { String url = "https://mysite.com/"; Document document = Jsoup.connect(url).get(); Elements images = document.select("img[src~=(?i)\\.(png|jpe?g|gif)]"); images.parents(); for (Element element : images) { System.out.println(element); } }
protected String getCSSSource(String htmlSource) throws Exception { org.jsoup.nodes.Document htmlDocument = Jsoup.parse(htmlSource); Elements elements = htmlDocument.select("link[type=text/css]"); StringBuilder sb = new StringBuilder(); for (Element element : elements) { String href = element.attr("href"); if (!href.contains(PropsValues.PORTAL_URL)) { href = PropsValues.PORTAL_URL + href; } Connection connection = Jsoup.connect(href); org.jsoup.nodes.Document document = connection.get(); sb.append(document.text()); sb.append("\n"); } return sb.toString(); }
public void cmdExportChildren() throws Exception { String path = cmdline.getOptionValue("znode"); String dir = cmdline.getOptionValue("dir"); Listkids = zkClient.getChildren(path); System.out.println(kids); for (String kid : kids) { exportPath(path + "/" + kid, dir); } }
/* * Bridge method used by donkey.js */ public Document jsoup(String url) { try { filterHostBlocker(); URL u = new URL(url); long li = lastInteraction.getOrDefault(u.getHost(), 0l); long delta = System.currentTimeMillis() - li; if (delta < 1000) { Wait.randomMillis(1000, 2000); } lastInteraction.put(u.getHost(), System.currentTimeMillis()); return Jsoup.connect(url) .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)") .followRedirects(true) .get(); } catch (IOException e) { Exceptions.handle(LOG, e); return null; } }
/** * getHtmlElement. * * @return a {@link org.jsoup.nodes.Element} object. */ public Element getHtmlElement() { if (this.html == null) { Element htmlElement = null; Document doc = Jsoup.parse(this.htmlText); List<Node> htmlNodes = doc.childNodes(); Node firstNode = htmlNodes.get(0); if (firstNode instanceof Element) { Element element = (Element) firstNode; Elements elements = element.select("body"); if (elements.size() > 0) { if (elements.first().children().size() == 1) { htmlElement = elements.first().child(0); } } if (htmlElement == null) { htmlElement = doc.child(0); } } this.html = htmlElement; } return this.html; }
public void testNullHMM() { ATable at = new ATable(true, 1, 5); int[] e1 = {-1,0,3,6}; int[]ef = {1,2,3,1,2,3}; TTable_monolithic tt = new TTable_monolithic(e1, ef, 4); tt.set(0, 1, 0.1f); tt.set(0, 2, 0.1f); tt.set(0, 3, 0.8f); tt.set(1, 1, 0.3f); tt.set(1, 2, 0.7f); tt.set(2, 1, 0.9f); tt.set(2, 2, 0.1f); at.add(1, 'a', 999, 0.3f); at.add(0, 'a', 999, 0.5f); at.add(-1, 'a', 999, 0.4f); at.add(-2, 'a', 999, 0.2f); at.normalize(); // System.out.println(at); int[] fw = {1, 3, 2, 1}; //int[] fw = {2, 1, 2}; int[] ew = {2, 1, 2}; Phrase f = new Phrase(fw, 1); Phrase e = new Phrase(ew, 1); PhrasePair pp = new PhrasePair(f, e); hmm = new HMM_NullWord(tt, at, -1.0); hmm.buildHMMTables(pp); hmm.baumWelch(pp, null); TTable_monolithic tc = (TTable_monolithic)tt.clone(); tc.clear(); ATable ac = (ATable)at.clone(); ac.clear(); hmm.addPartialTranslationCountsToTTable(tc); hmm.addPartialJumpCountsToATable(ac); System.out.println("COUNTS:\n" + tc); tc.normalize(); ac.normalize(); PerplexityReporter cr = new PerplexityReporter(); Alignment a = hmm.viterbiAlign(pp, cr); assertEquals(a.getELength(), e.size()); assertEquals(a.getFLength(), f.size()); AlignmentPosteriorGrid pg = hmm.computeAlignmentPosteriors(pp); System.out.println(a.toStringVisual() + "\nPG:\n"+pg + "\n"+cr + "\n"); System.out.println(hmm.emission); System.out.println(hmm.transition); System.out.println("Done NULL"); }
public static void getNewsFromSoccerFanSite() throws IOException { String url = "https://m.vocegiallorossa.it/"; Document document = Jsoup.connect(url).get(); Elements news = document.getElementsByClass("list"); news.append("news"); news.prepend(""); }
/** * Sets the URL. * @param String the URL * @return true if connection to URL is successful */ public boolean connect(String url) { try { this.url = url; this.document = Jsoup.connect(url).get(); Path path = Paths.get(url); File rootFile = new File(this.htmlDirectory.getAbsolutePath() + "/" + path.getName(path.getNameCount() - 1)); FileUtils.copyURLToFile(new URL(url), rootFile); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
private void getConnection(Info info, int position, String funName) { try { Document document = Jsoup.connect(getUrl(info, position)).userAgent(userAgent()).get(); Elements elements = null; if (info.getRootTag() != null && !"".equals(info.getRootTag())) { elements = document.select(info.getRootTag()).first().children(); } else { elements = document.children(); } for (Element ele : elements) { Mapmap = new HashMap (); for (Column column : info.getColumns()) { Object data = null; if (column.getAttr() == null || "html".equals(column.getAttr())) data = ele.select(column.getTag()).html(); else data = ele.select(column.getTag()).attr(column.getAttr()); if (column.getFun() != null && !"".equals(column.getFun())) data = column.function(invocable, funName, data); map.put(column.getName(), data); } if (getListener() != null) { getListener().accept(info, position, map); } } } catch (Exception e) { e.printStackTrace(); } }
private void addCukedoctorCss(org.jsoup.nodes.Document document) { List<String> files = FileUtil.findFiles(CUKEDOCTOR_CUSTOMIZATION_DIR, "cukedoctor.css", true); if(files != null && !files.isEmpty()) { String themePath = files.get(0); themePath = themePath.replaceAll("\\\\","/"); try { String customCss = IOUtils.toString(new FileInputStream(themePath)); Elements head = document.getElementsByTag("head"); head.append(" <style> "+customCss); } catch (IOException e) { log.log(Level.SEVERE, "Could not copy cukedoctor css from: " + themePath, e); } } }
private void populateQuotes() { Document doc; String quoteId = null; String quoteScore = null; try { doc = Jsoup.connect("http://bash.org/?random1").get(); } catch (IOException e) { log.error("could not get page", e); return; } for (Element element : doc.select("p.quote, p.qt")) { if (element.className().equals("quote")) { quoteId = element.select("b").first().text(); quoteScore = element.ownText(); } else { StringBuilder buffer = new StringBuilder(); ArrayListquote = new ArrayList (); String[] lines; for (Node node : element.childNodes()) { if (node instanceof TextNode) { buffer.append(((TextNode) node).text().trim()); } else if (node instanceof Element) { if (((Element) node).tagName().equals("br")) { buffer.append("\n"); } } } lines = buffer.toString().split("\n"); if (lines.length == 1) { quote.add(String.format("%s %s: %s", quoteId, quoteScore, lines[0])); } else { quote.add(String.format("%s %s:", quoteId, quoteScore)); for (String line : lines) { quote.add(" " + line); } } try { this.quotes.put(quote.toArray(new String[0])); } catch (InterruptedException e) { log.warn("interrupted while populating quotes"); return; } } } }
protected String getCSSSource(String htmlSource) throws Exception { org.jsoup.nodes.Document htmlDocument = Jsoup.parse(htmlSource); Elements elements = htmlDocument.select("link[type=text/css]"); StringBuilder sb = new StringBuilder(); for (Element element : elements) { String href = element.attr("href"); if (!href.contains(PropsValues.PORTAL_URL)) { href = PropsValues.PORTAL_URL + href; } Connection connection = Jsoup.connect(href); org.jsoup.nodes.Document document = connection.get(); sb.append(document.text()); sb.append("\n"); } return sb.toString(); }
public static void getScoresFromLivescore() throws IOException { String url = "https://www.livescore.com/"; Document document = Jsoup.connect(url).get(); Elements scores = document.getElementsByClass("sco"); scores.parents(); }
public Document crawl(String method, String url) { Document doc = null; if (url == null) { logger.warn("url is null"); return doc; } try { Connection conn = Jsoup.connect(url); for (String key : headers.keySet()) { conn.header(key, headers.get(key)); } conn.ignoreContentType(true); conn.timeout(5 * 1000); if (HTTPConstants.Method.GET.equals(method)) { doc = conn.get(); } else if (HTTPConstants.Method.POST.equals(method)) { doc = conn.post(); } } catch (Exception e) { logger.warn(e.getMessage()); } return doc; }
private void getConnection(Info info, int position, String funName) { try { Document document = Jsoup.connect(getUrl(info, position)).userAgent(userAgent()).get(); Elements elements = null; if (info.getRootTag() != null && !"".equals(info.getRootTag())) { elements = document.select(info.getRootTag()).first().children(); } else { elements = document.children(); } for (Element ele : elements) { Mapmap = new HashMap (); for (Column column : info.getColumns()) { Object data = null; if (column.getAttr() == null || "html".equals(column.getAttr())) data = ele.select(column.getTag()).html(); else data = ele.select(column.getTag()).attr(column.getAttr()); if (column.getFun() != null && !"".equals(column.getFun())) data = column.function(invocable, funName, data); map.put(column.getName(), data); } if (getListener() != null) { getListener().accept(info, position, map); } } } catch (Exception e) { e.printStackTrace(); } }
/** * Sets the URL. * @param String the URL * @return true if connection to URL is successful */ public boolean connect(String url) { try { this.url = url; this.document = Jsoup.connect(url).get(); Path path = Paths.get(url); File rootFile = new File(this.htmlDirectory.getAbsolutePath() + "/" + path.getName(path.getNameCount() - 1)); FileUtils.copyURLToFile(new URL(url), rootFile); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
/* * Bridge method used by donkey.js */ public Document jsoup(String url) { try { filterHostBlocker(); URL u = new URL(url); long li = lastInteraction.getOrDefault(u.getHost(), 0l); long delta = System.currentTimeMillis() - li; if (delta < 1000) { Wait.randomMillis(1000, 2000); } lastInteraction.put(u.getHost(), System.currentTimeMillis()); return Jsoup.connect(url) .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)") .followRedirects(true) .get(); } catch (IOException e) { Exceptions.handle(LOG, e); return null; } }
/* * (non-Javadoc) * @see org.phoenix.api.action.APIAction#getResponseByJsoup(java.lang.String, java.lang.String, java.util.HashMap, java.util.HashMap, java.util.HashMap, boolean, java.lang.String) */ @Override public Response getResponseByJsoup(String url, String method, HashMapcookies, HashMap datas, HashMap headers, boolean isFollowRedirects, String userAgent) { Connection conn = Jsoup.connect(url); if(headers != null){ for(Entry e:headers.entrySet()){ conn.header(e.getKey(), e.getValue()); } } if(datas != null) conn.data(datas); if(cookies != null)conn.cookies(cookies); if(userAgent != null)conn.userAgent(userAgent); conn.followRedirects(isFollowRedirects); if(method.equalsIgnoreCase("GET"))conn.method(Method.GET); else if(method.equalsIgnoreCase("POST"))conn.method(Method.POST); try { return conn.execute(); } catch (IOException e) { e.printStackTrace(); } return null; }
public static ListgetCityWheater() throws IOException { String url = "https://www.meteo.it/meteo/Abruzzo/"; Document document = Jsoup.connect(url).get(); Elements meteo = document.select("use"); /*TODO Complete the method here * ... */ return new ArrayList (); }
public ListgetLogList() { Elements logList = isChildNode ? test.select(".collapsible-body tbody > tr") : test.select(".test-body > .test-steps > table > tbody > tr"); ArrayList extentLogList = new ArrayList (); Log extentLog; for (Element log : logList) { extentLog = new Log(); extentLog.setTimestamp( DateTimeUtil.getDate( log.select(".timestamp").first().text(), getLogTimeFormat() ) ); if (log.select(".step-name").size() == 1) { extentLog.setStepName(log.select(".step-name").first().text()); } LogStatus status = getStatusStringMarkup(log.select(".status").first()); extentLog.setLogStatus(status); extentLog.setDetails(log.select(".step-details").first().html()); extentLogList.add(extentLog); } return extentLogList; }
/* * Bridge method used by donkey.js */ public Document jsoup(String url) { try { filterHostBlocker(); URL u = new URL(url); long li = lastInteraction.getOrDefault(u.getHost(), 0l); long delta = System.currentTimeMillis() - li; if (delta < 1000) { Wait.randomMillis(1000, 2000); } lastInteraction.put(u.getHost(), System.currentTimeMillis()); return Jsoup.connect(url) .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)") .followRedirects(true) .get(); } catch (IOException e) { Exceptions.handle(LOG, e); return null; } }
protected String getCSSSource(String htmlSource) throws Exception { org.jsoup.nodes.Document htmlDocument = Jsoup.parse(htmlSource); Elements elements = htmlDocument.select("link[type=text/css]"); StringBuilder sb = new StringBuilder(); for (Element element : elements) { String href = element.attr("href"); if (!href.contains(PropsValues.PORTAL_URL)) { href = PropsValues.PORTAL_URL + href; } Connection connection = Jsoup.connect(href); org.jsoup.nodes.Document document = connection.get(); sb.append(document.text()); sb.append("\n"); } return sb.toString(); }
private void getConnection(Info info, int position, String funName) { try { Document document = Jsoup.connect(getUrl(info, position)).userAgent(userAgent()).get(); Elements elements = null; if (info.getRootTag() != null && !"".equals(info.getRootTag())) { elements = document.select(info.getRootTag()).first().children(); } else { elements = document.children(); } for (Element ele : elements) { Mapmap = new HashMap (); for (Column column : info.getColumns()) { Object data = null; if (column.getAttr() == null || "html".equals(column.getAttr())) data = ele.select(column.getTag()).html(); else data = ele.select(column.getTag()).attr(column.getAttr()); if (column.getFun() != null && !"".equals(column.getFun())) data = column.function(invocable, funName, data); map.put(column.getName(), data); } if (getListener() != null) { getListener().accept(info, position, map); } } } catch (Exception e) { e.printStackTrace(); } }
private String[] parse(final String command) { final Pattern pattern = Pattern.compile("\"([^\"]*)\"|(\\S+)"); final Matcher matcher = pattern.matcher(command); final Listtokens = new ArrayList (); while (matcher.find()) { if (matcher.group(1) == null) { tokens.add(matcher.group()); } else { tokens.add(matcher.group(1)); } } return tokens.toArray(new String[tokens.size()]); }
public static Options getOptions() { final Options options = new Options(); final Option urlOption = new Option("url", true, "A database url of the form jdbc:subprotocol:subname"); final OptionGroup urlGroup = new OptionGroup(); urlGroup.setRequired(true); urlGroup.addOption(urlOption); options.addOptionGroup(urlGroup); return options; }
public static void main(String[] args) { final Options options = new Options(); Option lsOption = new Option("ls", true, "list zp path contents"); lsOption.setArgName("path"); Option readOption = new Option("read", true, "read and print zp path contents"); readOption.setArgName("path"); Option rmOption = new Option("rm", true, "remove zk files"); rmOption.setArgName("path"); Option rmrOption = new Option("rmr", true, "remove zk directories"); rmrOption.setArgName("path"); OptionGroup actionGroup = new OptionGroup(); actionGroup.setRequired(true); actionGroup.addOption(lsOption); actionGroup.addOption(readOption); actionGroup.addOption(rmOption); actionGroup.addOption(rmrOption); options.addOptionGroup(actionGroup); final CommandLineParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); try { final CommandLine line = parser.parse(options, args); ZkTool zkTool = new ZkTool(); if (line.hasOption(lsOption.getOpt())) { String path = line.getOptionValue(lsOption.getOpt()); zkTool.ls(path); } else if (line.hasOption(readOption.getOpt())) { String path = line.getOptionValue(readOption.getOpt()); zkTool.read(path); } else if (line.hasOption(rmOption.getOpt())) { String path = line.getOptionValue(rmOption.getOpt()); zkTool.rm(path, false); } else if (line.hasOption(rmrOption.getOpt())) { String path = line.getOptionValue(rmrOption.getOpt()); zkTool.rm(path, true); } zkTool.close(); } catch (ParseException e) { System.out.println(e.getClass().getSimpleName() + ": " + e.getMessage()); formatter.printHelp(ZkTool.class.getSimpleName(), options); } }
public static void main(final String[] args) throws IOException { final Console console = new Console(); final Option helpOption = new Option("h", "help", false, "print this help"); final Option versionOption = new Option("v", "version", false, "print version information"); final Option serverURLOption = new Option("s", "serverURL", true, "URL of Sesame server to connect to, e.g. http://localhost/openrdf-sesame/"); final Option dirOption = new Option("d", "dataDir", true, "Sesame data dir to 'connect' to"); Option echoOption = new Option("e", "echo", false, "echoes input back to stdout, useful for logging script sessions"); Option quietOption = new Option("q", "quiet", false, "suppresses prompts, useful for scripting"); Option forceOption = new Option("f", "force", false, "always answer yes to (suppressed) confirmation prompts"); Option cautiousOption = new Option("c", "cautious", false, "always answer no to (suppressed) confirmation prompts"); Option exitOnErrorMode = new Option("x", "exitOnError", false, "immediately exit the console on the first error"); final Options options = new Options(); OptionGroup cautionGroup = new OptionGroup().addOption(cautiousOption).addOption(forceOption).addOption( exitOnErrorMode); OptionGroup locationGroup = new OptionGroup().addOption(serverURLOption).addOption(dirOption); options.addOptionGroup(locationGroup).addOptionGroup(cautionGroup); options.addOption(helpOption).addOption(versionOption).addOption(echoOption).addOption(quietOption); CommandLine commandLine = parseCommandLine(args, console, options); handleInfoOptions(console, helpOption, versionOption, options, commandLine); console.consoleIO.setEcho(commandLine.hasOption(echoOption.getOpt())); console.consoleIO.setQuiet(commandLine.hasOption(quietOption.getOpt())); exitOnError = commandLine.hasOption(exitOnErrorMode.getOpt()); String location = handleOptionGroups(console, serverURLOption, dirOption, forceOption, cautiousOption, options, cautionGroup, locationGroup, commandLine); final String[] otherArgs = commandLine.getArgs(); if (otherArgs.length > 1) { printUsage(console.consoleIO, options); System.exit(1); } connectAndOpen(console, locationGroup.getSelected(), location, otherArgs); console.start(); }
public static void main(final String[] args) throws IOException { final Console console = new Console(); final Option helpOption = new Option("h", "help", false, "print this help"); final Option versionOption = new Option("v", "version", false, "print version information"); final Option serverURLOption = new Option("s", "serverURL", true, "URL of RDF4J Server to connect to, e.g. http://localhost:8080/rdf4j-server/"); final Option dirOption = new Option("d", "dataDir", true, "data dir to 'connect' to"); Option echoOption = new Option("e", "echo", false, "echoes input back to stdout, useful for logging script sessions"); Option quietOption = new Option("q", "quiet", false, "suppresses prompts, useful for scripting"); Option forceOption = new Option("f", "force", false, "always answer yes to (suppressed) confirmation prompts"); Option cautiousOption = new Option("c", "cautious", false, "always answer no to (suppressed) confirmation prompts"); Option exitOnErrorMode = new Option("x", "exitOnError", false, "immediately exit the console on the first error"); final Options options = new Options(); OptionGroup cautionGroup = new OptionGroup().addOption(cautiousOption).addOption( forceOption).addOption(exitOnErrorMode); OptionGroup locationGroup = new OptionGroup().addOption(serverURLOption).addOption(dirOption); options.addOptionGroup(locationGroup).addOptionGroup(cautionGroup); options.addOption(helpOption).addOption(versionOption).addOption(echoOption).addOption(quietOption); CommandLine commandLine = parseCommandLine(args, console, options); handleInfoOptions(console, helpOption, versionOption, options, commandLine); console.consoleIO.setEcho(commandLine.hasOption(echoOption.getOpt())); console.consoleIO.setQuiet(commandLine.hasOption(quietOption.getOpt())); exitOnError = commandLine.hasOption(exitOnErrorMode.getOpt()); String location = handleOptionGroups(console, serverURLOption, dirOption, forceOption, cautiousOption, options, cautionGroup, locationGroup, commandLine); final String[] otherArgs = commandLine.getArgs(); if (otherArgs.length > 1) { printUsage(console.consoleIO, options); System.exit(1); } connectAndOpen(console, locationGroup.getSelected(), location, otherArgs); console.start(); }
@SuppressWarnings("static-access") private void createOptions() { Option sourceOption = OptionBuilder.hasArg().isRequired().withLongOpt(SOURCE_SESSION).withDescription( "The name of the source alias to copy tables from").create(); options.addOption(sourceOption); Option destOption = OptionBuilder.hasArg().isRequired().withLongOpt(DEST_SESSION).withDescription( "The name of the destination alias to copy tables to").create(); options.addOption(destOption); Option sourceSchemaOption = OptionBuilder.hasArg().withLongOpt(SOURCE_SCHEMA).withDescription( "The source schema to copy tables from").create(); Option sourceCatalogOption = OptionBuilder.hasArg().withLongOpt(SOURCE_CATALOG).withDescription( "The source catalog to copy tables from").create(); OptionGroup sourceSchemaGroup = new OptionGroup(); sourceSchemaGroup.setRequired(true); sourceSchemaGroup.addOption(sourceSchemaOption); sourceSchemaGroup.addOption(sourceCatalogOption); options.addOptionGroup(sourceSchemaGroup); Option listOption = OptionBuilder.hasArg().withLongOpt(TABLE_LIST).withDescription( "A comma-delimited list of tables to copy").create(); Option patternOption = OptionBuilder.hasArg().withLongOpt(TABLE_PATTERN).withDescription( "A regexp pattern to match source table names").create(); OptionGroup tableGroup = new OptionGroup(); tableGroup.setRequired(true); tableGroup.addOption(listOption); tableGroup.addOption(patternOption); options.addOptionGroup(tableGroup); Option destSchemaOption = OptionBuilder.hasArg().withLongOpt(DEST_SCHEMA).withDescription( "The destination schema to copy tables into").create(); Option destCatalogOption = OptionBuilder.hasArg().withLongOpt(DEST_CATALOG).withDescription( "The destination catalog to copy tables into").create(); OptionGroup destSchemaGroup = new OptionGroup(); destSchemaGroup.setRequired(true); destSchemaGroup.addOption(destSchemaOption); destSchemaGroup.addOption(destCatalogOption); options.addOptionGroup(destSchemaGroup); }
/** * Create option for command line option 'job' * @return job options */ protected Options createJobOptions() { Option oozie = new Option(OOZIE_OPTION, true, "Oozie URL"); Option config = new Option(CONFIG_OPTION, true, "job configuration file '.xml' or '.properties'"); Option submit = new Option(SUBMIT_OPTION, false, "submit a job"); Option run = new Option(RUN_OPTION, false, "run a job"); Option debug = new Option(DEBUG_OPTION, false, "Use debug mode to see debugging statements on stdout"); Option rerun = new Option(RERUN_OPTION, true, "rerun a job (coordinator requires -action or -date, bundle requires -coordinator or -date)"); Option dryrun = new Option(DRYRUN_OPTION, false, "Dryrun a workflow (since 3.3.2) or coordinator (since 2.0) job without" + " actually executing it"); Option update = new Option(UPDATE_OPTION, true, "Update coord definition and properties"); Option showdiff = new Option(SHOWDIFF_OPTION, true, "Show diff of the new coord definition and properties with the existing one (default true)"); Option start = new Option(START_OPTION, true, "start a job"); Option suspend = new Option(SUSPEND_OPTION, true, "suspend a job"); Option resume = new Option(RESUME_OPTION, true, "resume a job"); Option kill = new Option(KILL_OPTION, true, "kill a job (coordinator can mention -action or -date)"); Option change = new Option(CHANGE_OPTION, true, "change a coordinator or bundle job"); Option changeValue = new Option(CHANGE_VALUE_OPTION, true, "new endtime/concurrency/pausetime value for changing a coordinator job"); Option info = new Option(INFO_OPTION, true, "info of a job"); Option poll = new Option(POLL_OPTION, true, "poll Oozie until a job reaches a terminal state or a timeout occurs"); Option offset = new Option(OFFSET_OPTION, true, "job info offset of actions (default '1', requires -info)"); Option len = new Option(LEN_OPTION, true, "number of actions (default TOTAL ACTIONS, requires -info)"); Option filter = new Option(FILTER_OPTION, true, "[; ]*\n" + "(All Coordinator actions satisfying the filters will be retreived).\n" + "key: status or nominaltime\n" + "comparator: =, !=, <, <=, >, >=. = is used as OR and others as AND\n" + "status: values are valid status like SUCCEEDED, KILLED etc. Only = and != apply for status\n" + "nominaltime: time of format yyyy-MM-dd'T'HH:mm'Z'"); Option order = new Option(ORDER_OPTION, true, "order to show coord actions (default ascending order, 'desc' for descending order, requires -info)"); Option localtime = new Option(LOCAL_TIME_OPTION, false, "use local time (same as passing your time zone to -" + TIME_ZONE_OPTION + "). Overrides -" + TIME_ZONE_OPTION + " option"); Option timezone = new Option(TIME_ZONE_OPTION, true, "use time zone with the specified ID (default GMT).\nSee 'oozie info -timezones' for a list"); Option log = new Option(LOG_OPTION, true, "job log"); Option errorlog = new Option(ERROR_LOG_OPTION, true, "job error log"); Option auditlog = new Option(AUDIT_LOG_OPTION, true, "job audit log"); Option logFilter = new Option( RestConstants.LOG_FILTER_OPTION, true, "job log search parameter. Can be specified as -logfilter opt1=val1;opt2=val1;opt3=val1. " + "Supported options are recent, start, end, loglevel, text, limit and debug"); Option definition = new Option(DEFINITION_OPTION, true, "job definition"); Option config_content = new Option(CONFIG_CONTENT_OPTION, true, "job configuration"); Option verbose = new Option(VERBOSE_OPTION, false, "verbose mode"); Option action = new Option(ACTION_OPTION, true, "coordinator rerun/kill on action ids (requires -rerun/-kill); coordinator log retrieval on action ids" + "(requires -log)"); Option date = new Option(DATE_OPTION, true, "coordinator/bundle rerun on action dates (requires -rerun); coordinator log retrieval on action dates (requires -log)"); Option rerun_coord = new Option(COORD_OPTION, true, "bundle rerun on coordinator names (requires -rerun)"); Option rerun_refresh = new Option(RERUN_REFRESH_OPTION, false, "re-materialize the coordinator rerun actions (requires -rerun)"); Option rerun_nocleanup = new Option(RERUN_NOCLEANUP_OPTION, false, "do not clean up output-events of the coordiantor rerun actions (requires -rerun)"); Option rerun_failed = new Option(RERUN_FAILED_OPTION, false, "runs the failed workflow actions of the coordinator actions (requires -rerun)"); Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator().withDescription( "set/override value for given property").create("D"); Option getAllWorkflows = new Option(ALL_WORKFLOWS_FOR_COORD_ACTION, false, "Get workflow jobs corresponding to a coordinator action including all the reruns"); Option ignore = new Option(IGNORE_OPTION, true, "change status of a coordinator job or action to IGNORED" + " (-action required to ignore coord actions)"); Option timeout = new Option(TIMEOUT_OPTION, true, "timeout in minutes (default is 30, negative values indicate no " + "timeout, requires -poll)"); timeout.setType(Integer.class); Option interval = new Option(INTERVAL_OPTION, true, "polling interval in minutes (default is 5, requires -poll)"); interval.setType(Integer.class); Option slaDisableAlert = new Option(SLA_DISABLE_ALERT, true, "disables sla alerts for the job and its children"); Option slaEnableAlert = new Option(SLA_ENABLE_ALERT, true, "enables sla alerts for the job and its children"); Option slaChange = new Option(SLA_CHANGE, true, "Update sla param for jobs, supported param are should-start, should-end, nominal-time and max-duration"); Option doAs = new Option(DO_AS_OPTION, true, "doAs user, impersonates as the specified user"); OptionGroup actions = new OptionGroup(); actions.addOption(submit); actions.addOption(start); actions.addOption(run); actions.addOption(dryrun); actions.addOption(suspend); actions.addOption(resume); actions.addOption(kill); actions.addOption(change); actions.addOption(update); actions.addOption(info); actions.addOption(rerun); actions.addOption(log); actions.addOption(errorlog); actions.addOption(auditlog); actions.addOption(definition); actions.addOption(config_content); actions.addOption(ignore); actions.addOption(poll); actions.addOption(slaDisableAlert); actions.addOption(slaEnableAlert); actions.addOption(slaChange); actions.setRequired(true); Options jobOptions = new Options(); jobOptions.addOption(oozie); jobOptions.addOption(doAs); jobOptions.addOption(config); jobOptions.addOption(property); jobOptions.addOption(changeValue); jobOptions.addOption(localtime); jobOptions.addOption(timezone); jobOptions.addOption(verbose); jobOptions.addOption(debug); jobOptions.addOption(offset); jobOptions.addOption(len); jobOptions.addOption(filter); jobOptions.addOption(order); jobOptions.addOption(action); jobOptions.addOption(date); jobOptions.addOption(rerun_coord); jobOptions.addOption(rerun_refresh); jobOptions.addOption(rerun_nocleanup); jobOptions.addOption(rerun_failed); jobOptions.addOption(getAllWorkflows); jobOptions.addOptionGroup(actions); jobOptions.addOption(logFilter); jobOptions.addOption(timeout); jobOptions.addOption(interval); addAuthOptions(jobOptions); jobOptions.addOption(showdiff); //Needed to make dryrun and update mutually exclusive options OptionGroup updateOption = new OptionGroup(); updateOption.addOption(dryrun); jobOptions.addOptionGroup(updateOption); return jobOptions; }
public static void main(String[] args) { try { CommandLineParser parser = new GnuParser(); CommandLine cmdLine = parser.parse(getOptions(), args); if(!cmdLine.hasOption("url")) throw new ParseException("No url is specifified"); String url = cmdLine.getOptionValue("url"); String username = "", password = "", sql = "", file = "", protocol = ""; //Complete the parameter parser code //HERE // boolean includeHeaders = false; businessLogic(protocol, url, username, password, sql, file, includeHeaders); } catch (ParseException pe) { printUsage(); } }
/** * Parses command line parameters. * * @param args command line parameters * @return command line arguments and options */ public CmdLineArgs parse(String[] args) { CmdLineArgs cmdArgs = new CmdLineArgs(); // Process command line arguments try { CommandLineParser cmdLineParser = new GnuParser(); Options cmdOptions = getCmdOptions(); CommandLine commandLine = cmdLineParser.parse(cmdOptions, args); if (commandLine.hasOption(JAR_PATH_OPTION_NAME)) { cmdArgs.setJarpath(commandLine.getOptionValue(JAR_PATH_OPTION_NAME)); } if (commandLine.hasOption(OUTPUT_XML_PATH_OPTION_NAME)) { cmdArgs.setOutpath(commandLine.getOptionValue(OUTPUT_XML_PATH_OPTION_NAME)); } if (commandLine.hasOption(TYPES_XML_PATH_OPTION_NAME)) { cmdArgs.setTypesXmlPath(commandLine.getOptionValue(TYPES_XML_PATH_OPTION_NAME)); } cmdArgs.setHelp(commandLine.hasOption(HELP_OPTION_NAME)); cmdArgs.setExportTypes(commandLine.hasOption(TYPE_EXPORT_OPTION_NAME)); cmdArgs.setExportMessages(commandLine.hasOption(MSG_EXPORT_OPTION_NAME)); cmdArgs.setQuietReflectionErrors(commandLine.hasOption(QUIET_REFLECTION_ERRORS_OPTION_NAME)); cmdArgs.setGenerateTypes(commandLine.hasOption(GENERATE_TYPES_OPTION_NAME)); if (!cmdArgs.hasHelpOption()) { if (commandLine.getArgs().length == 0) { throw new RuntimeException("Source file is not defined"); } if (commandLine.getArgs().length > 1) { throw new RuntimeException("Cannot resolve source file"); } cmdArgs.setSourcepath(commandLine.getArgs()[0]); } } catch (ParseException parseException) { LOG.error("Encountered exception while parsing command line arguments", parseException); } if (LOG.isDebugEnabled()) { LOG.debug(cmdArgs.toString()); } return cmdArgs; }
private void handleNetezzaExtraArgs(SqoopOptions opts) throws ParseException { Configuration conf = opts.getConf(); String[] extraArgs = opts.getExtraArgs(); RelatedOptions netezzaOpts = getNetezzaExtraOpts(); CommandLine cmdLine = new GnuParser().parse(netezzaOpts, extraArgs, true); if (cmdLine.hasOption(NETEZZA_ERROR_THRESHOLD_LONG_ARG)) { int threshold = Integer.parseInt(cmdLine .getOptionValue(NETEZZA_ERROR_THRESHOLD_LONG_ARG)); conf.setInt(NETEZZA_ERROR_THRESHOLD_OPT, threshold); } if (cmdLine.hasOption(NETEZZA_LOG_DIR_LONG_ARG)) { String dir = cmdLine.getOptionValue(NETEZZA_LOG_DIR_LONG_ARG); conf.set(NETEZZA_LOG_DIR_OPT, dir); } if (cmdLine.hasOption(NETEZZA_TABLE_ENCODING_LONG_ARG)) { String encoding = cmdLine .getOptionValue(NETEZZA_TABLE_ENCODING_LONG_ARG); conf.set(NETEZZA_TABLE_ENCODING_OPT, encoding); } conf.setBoolean(NETEZZA_CTRL_CHARS_OPT, cmdLine.hasOption(NETEZZA_CTRL_CHARS_LONG_ARG)); conf.setBoolean(NETEZZA_TRUNC_STRING_OPT, cmdLine.hasOption(NETEZZA_TRUNC_STRING_LONG_ARG)); conf.setBoolean(NETEZZA_CRIN_STRING_OPT, cmdLine.hasOption(NETEZZA_CRIN_STRING_LONG_ARG)); conf.setBoolean(NETEZZA_IGNORE_ZERO_OPT, cmdLine.hasOption(NETEZZA_IGNORE_ZERO_LONG_ARG)); // Always true for Netezza direct mode access conf.setBoolean(NETEZZA_DATASLICE_ALIGNED_ACCESS_OPT, true); }
@Override public int run(String[] args) throws Exception { Options opts = new Options(); opts.addOption(STATUS_CMD, true, "List queue information about given queue."); opts.addOption(HELP_CMD, false, "Displays help for all commands."); opts.getOption(STATUS_CMD).setArgName("Queue Name"); CommandLine cliParser = null; try { cliParser = new GnuParser().parse(opts, args); } catch (MissingArgumentException ex) { sysout.println("Missing argument for options"); printUsage(opts); return -1; } if (cliParser.hasOption(STATUS_CMD)) { if (args.length != 2) { printUsage(opts); return -1; } return listQueue(cliParser.getOptionValue(STATUS_CMD)); } else if (cliParser.hasOption(HELP_CMD)) { printUsage(opts); return 0; } else { syserr.println("Invalid Command Usage : "); printUsage(opts); return -1; } }
/** * @param args * @throws Exception */ public static void main(final String[] args) throws Exception { final Parser parser = new GnuParser(); final HelpFormatter formatter = new HelpFormatter(); final Options options = new Options(); options.addOption("c", CACHE, true, "chache directory (mandatory!)"); options.addOption("s", SERVER, true, "server name and port number as server:port"); options.addOption("x", USE_SSL, false, "use ssl"); options.addOption("?", HELP, false, "display help"); final CommandLine cli = parser.parse(options, args); final String server = cli.getOptionValue(SERVER); final String cache = cli.getOptionValue(CACHE); final boolean ssl = cli.hasOption(USE_SSL); if (cli.hasOption(HELP) || cache == null) { formatter.printHelp(CachingRESTProxy.class.getName(), options); return; } final CachingRESTProxy proxy = new CachingRESTProxy(ssl, server, new File(cache)); proxy.start(); }
protected SyncOptimizeConfig processOptions(String[] args) throws ParseException { CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(cmdOptions, args); SyncOptimizeConfig config = new SyncOptimizeConfig(); config.setContext(DEFAULT_CONTEXT); config.setHost(cmd.getOptionValue("h")); config.setUsername(cmd.getOptionValue("u")); config.setSpaceId(cmd.getOptionValue("s")); if (null != cmd.getOptionValue("p")) { config.setPassword(cmd.getOptionValue("p")); } else if (null != getPasswordEnvVariable()) { config.setPassword(getPasswordEnvVariable()); } else { ConsolePrompt console = getConsole(); if (null == console) { printHelp("You must either specify a password in the command "+ "line or specify the " + CommandLineToolUtil.PASSWORD_ENV_VARIABLE_NAME + " environmental variable."); } else { char[] password = console.readPassword("DuraCloud password: "); config.setPassword(new String(password)); } } if(cmd.hasOption("r")) { try { config.setPort(Integer.valueOf(cmd.getOptionValue("r"))); } catch(NumberFormatException e) { throw new ParseException("The value for port (-r) must be " + "a number."); } } else { config.setPort(DEFAULT_PORT); } if(cmd.hasOption("n")) { try { config.setNumFiles(Integer.valueOf(cmd.getOptionValue("n"))); } catch(NumberFormatException e) { throw new ParseException("The value for num-files (-n) must " + "be a number."); } } else { config.setNumFiles(DEFAULT_NUM_FILES); } if(cmd.hasOption("m")) { try { config.setSizeFiles(Integer.valueOf(cmd.getOptionValue("m"))); } catch(NumberFormatException e) { throw new ParseException("The value for size-files (-m) must " + "be a number."); } } else { config.setSizeFiles(DEFAULT_SIZE_FILES); } return config; }
private static void businessLogic(String protocol, String url, String username, String password, String sql, String file, boolean includeHeaders) { SQLDump dump = new SQLDump(Connector.valueOf(protocol), url, username, password, sql); if (!file.isEmpty()) dump.setFile(new File(file)); if (includeHeaders) dump.setHeaders(true); dump.run(); }
private void insertReport() { ObjectId projectId = getProjectId(); String id = report.getMongoDBObjectID(); // if extent is started with [replaceExisting = false] and ExtentX is used, // use the same report ID for the 1st report run and update the database for // the corresponding report-ID if (id != null & !id.isEmpty()) { FindIterableiterable = reportCollection.find(new Document("_id", new ObjectId(id))); Document report = iterable.first(); if (report != null) { reportId = report.getObjectId("_id"); return; } } // if [replaceExisting = true] or the file does not exist, create a new // report-ID and assign all components to it Document doc = new Document("project", projectId) .append("fileName", new File(report.getFilePath()).getName()) .append("startTime", report.getStartedTime()); reportCollection.insertOne(doc); reportId = MongoUtil.getId(doc); report.setMongoDBObjectID(reportId.toString()); }
private void findRootUrlsFile() { File manageFile = new File(rootDirectory, "manage.py"); assert manageFile.exists() : "manage.py does not exist in root directory"; SettingsFinder settingsFinder = new SettingsFinder(); EventBasedTokenizerRunner.run(manageFile, settingsFinder); File settingsFile = settingsFinder.getSettings(rootDirectory.getPath()); //assert settingsFile.exists() : "Settings file not found"; UrlFileFinder urlFileFinder = new UrlFileFinder(); if (settingsFile.isDirectory()) { for (File file : settingsFile.listFiles()) { EventBasedTokenizerRunner.run(file, PythonTokenizerConfigurator.INSTANCE, urlFileFinder); if (!urlFileFinder.shouldContinue()) break; } } else { settingsFile = new File(settingsFile.getAbsolutePath().concat(".py")); EventBasedTokenizerRunner.run(settingsFile, urlFileFinder); } //assert !urlFileFinder.getUrlFile().isEmpty() : "Root URL file setting does not exist."; if (!urlFileFinder.getUrlFile().isEmpty()) { rootUrlsFile = new File(rootDirectory, urlFileFinder.getUrlFile()); } }
/** * Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system properties * required to change the proxy server, port, and connection timeout. */ private void populateSettings() { Settings.initialize(); if (dataDirectory != null) { Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory); } else { final File jarPath = new File(DependencyCheckScanAgent.class.getProtectionDomain().getCodeSource().getLocation().getPath()); final File base = jarPath.getParentFile(); final String sub = Settings.getString(Settings.KEYS.DATA_DIRECTORY); final File dataDir = new File(base, sub); Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDir.getAbsolutePath()); } Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); if (proxyServer != null && !proxyServer.isEmpty()) { Settings.setString(Settings.KEYS.PROXY_SERVER, proxyServer); } if (proxyPort != null && !proxyPort.isEmpty()) { Settings.setString(Settings.KEYS.PROXY_PORT, proxyPort); } if (proxyUsername != null && !proxyUsername.isEmpty()) { Settings.setString(Settings.KEYS.PROXY_USERNAME, proxyUsername); } if (proxyPassword != null && !proxyPassword.isEmpty()) { Settings.setString(Settings.KEYS.PROXY_PASSWORD, proxyPassword); } if (connectionTimeout != null && !connectionTimeout.isEmpty()) { Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout); } if (suppressionFile != null && !suppressionFile.isEmpty()) { Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile); } Settings.setBoolean(Settings.KEYS.ANALYZER_CENTRAL_ENABLED, centralAnalyzerEnabled); if (centralUrl != null && !centralUrl.isEmpty()) { Settings.setString(Settings.KEYS.ANALYZER_CENTRAL_URL, centralUrl); } Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, nexusAnalyzerEnabled); if (nexusUrl != null && !nexusUrl.isEmpty()) { Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl); } Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy); if (databaseDriverName != null && !databaseDriverName.isEmpty()) { Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName); } if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) { Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath); } if (connectionString != null && !connectionString.isEmpty()) { Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString); } if (databaseUser != null && !databaseUser.isEmpty()) { Settings.setString(Settings.KEYS.DB_USER, databaseUser); } if (databasePassword != null && !databasePassword.isEmpty()) { Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword); } if (zipExtensions != null && !zipExtensions.isEmpty()) { Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, zipExtensions); } if (cveUrl12Modified != null && !cveUrl12Modified.isEmpty()) { Settings.setString(Settings.KEYS.CVE_MODIFIED_12_URL, cveUrl12Modified); } if (cveUrl20Modified != null && !cveUrl20Modified.isEmpty()) { Settings.setString(Settings.KEYS.CVE_MODIFIED_20_URL, cveUrl20Modified); } if (cveUrl12Base != null && !cveUrl12Base.isEmpty()) { Settings.setString(Settings.KEYS.CVE_SCHEMA_1_2, cveUrl12Base); } if (cveUrl20Base != null && !cveUrl20Base.isEmpty()) { Settings.setString(Settings.KEYS.CVE_SCHEMA_2_0, cveUrl20Base); } if (pathToMono != null && !pathToMono.isEmpty()) { Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono); } }
@Override public int complete(String buf, int arg1, Listcandidates) { String buffer = (buf == null) ? "" : buf; String subString = null; int index = buf.lastIndexOf("--" + CliConstants.RESOURCE_PATH_LONG_OPTION); if (buf.length() >= index + 16) { subString = buf.substring(index + 16); } String translated = (subString == null || subString.isEmpty()) ? buf : subString; if (translated.startsWith("~" + File.separator)) { translated = System.getProperty("user.home") + translated.substring(1); } else if (translated.startsWith("." + File.separator)) { translated = new File("").getAbsolutePath() + File.separator + translated; } File f = new File(translated); final File dir; if (translated.endsWith(File.separator)) { dir = f; } else { dir = f.getParentFile(); } final File[] entries = (dir == null) ? new File[0] : dir.listFiles(); return matchFiles(buffer, translated, entries, candidates); }
/** * <p> * Get the preferences file name. * </p> * <p> * The preferences file is defined through the environment variable * {@value #PREFERENCE_ENV_VAR}, otherwise it is defined by the resource * {@value #PREFERENCE_FILE_NAME} of the classpath. * </p> * * @return The preferences file name, or <code>null</code> if the default * preference resource ({@value #PREFERENCE_FILE_NAME}) can not be * found on the classpath */ static final File getPreferenceFile() { final String preferenceEnvVarPath = System.getenv(PREFERENCE_ENV_VAR); File preferenceFilePath = null; if (preferenceEnvVarPath == null || preferenceEnvVarPath.trim().isEmpty()) { final URL defaultPrefFileUrl = Thread.currentThread().getContextClassLoader().getResource(PREFERENCE_FILE_NAME); try { if (defaultPrefFileUrl != null) { preferenceFilePath = new File(defaultPrefFileUrl.toURI()); } } catch (final URISyntaxException e) { // NOP: this exception has not to occur } } else { preferenceFilePath = new File(preferenceEnvVarPath); } return preferenceFilePath; }
public static void printUsage() { HelpFormatter printer = new HelpFormatter(); //Complete the helper code //HERE // }
protected boolean parseCommandline(final String[] args) { try { _commandLine = new PosixParser().parse(OPTIONS, args); return true; } catch (ParseException e) { System.err.println("Error: " + e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Qpid", OPTIONS, true); return false; } }
public static void main(String[] args) throws Exception { CommandLine cmd = new GnuParser().parse(opts, args); if (cmd.hasOption("help")) { new HelpFormatter().printHelp("Usage: hbgen [OPTIONS]", opts); return; } // defaults Class> specClass = HamletSpec.class; Class> implClass = HamletImpl.class; String outputClass = "HamletTmp"; String outputPackage = implClass.getPackage().getName(); if (cmd.hasOption("spec-class")) { specClass = Class.forName(cmd.getOptionValue("spec-class")); } if (cmd.hasOption("impl-class")) { implClass = Class.forName(cmd.getOptionValue("impl-class")); } if (cmd.hasOption("output-class")) { outputClass = cmd.getOptionValue("output-class"); } if (cmd.hasOption("output-package")) { outputPackage = cmd.getOptionValue("output-package"); } new HamletGen().generate(specClass, implClass, outputClass, outputPackage); }
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(ARG_COLLECTION, true, "File name of the POSTMAN collection."); options.addOption(ARG_ENVIRONMENT, true, "File name of the POSTMAN environment variables."); options.addOption(ARG_FOLDER, true, "(Optional) POSTMAN collection folder (group) to execute i.e. \"My Use Cases\""); options.addOption(ARG_HALTONERROR, false, "(Optional) Stop on first error in POSTMAN folder."); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); String colFilename = cmd.getOptionValue(ARG_COLLECTION); String envFilename = cmd.getOptionValue(ARG_ENVIRONMENT); String folderName = cmd.getOptionValue(ARG_FOLDER); boolean haltOnError = cmd.hasOption(ARG_HALTONERROR); if (colFilename == null || colFilename.isEmpty() || envFilename == null || envFilename.isEmpty()) { // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("postman-runner", options); return; } PostmanCollectionRunner pcr = new PostmanCollectionRunner(); pcr.runCollection(colFilename, envFilename, folderName, haltOnError, false); }
private static void showHelp() { final HelpFormatter formatter = new HelpFormatter(); final PrintWriter pw = new PrintWriter(System.err); final String version = JSCMain.getVersion(); pw.println("jsc: [options] --check file"); pw.println(" or [options] --xhtml-single file outdir"); pw.println(" or [options] --xhtml-multi file outdir"); pw.println(" or [options] --version"); pw.println(); formatter.printOptions(pw, 120, JSCMain.OPTIONS, 2, 4); pw.println(); pw.println(" Version: " + version); pw.println(); pw.flush(); }
private void doExport(ListcommandArgs) { Options options = new OptionBuilder() .createOptions(); try { CommandLineParser parser = new PosixParser(); CommandLine cmdLine = parser.parse(options, commandArgs.toArray( new String[commandArgs.size()])); if (cmdLine.getArgs().length < 2) { throw new ParseException( "Needs two arguments: corpus name and output folder"); } annisDao.exportCorpus(cmdLine.getArgs()[0], new File(cmdLine.getArgs()[1])); } catch (ParseException ex) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp("annis-admin.sh export CORPUS DIR ...", options); } }