List of usage examples for org.apache.commons.cli Options Options
Options
From source file:com.aerospike.example.cache.AsACache.java
public static void main(String[] args) throws AerospikeException { try {//from w w w. j a va 2s.c om Options options = new Options(); options.addOption("h", "host", true, "Server hostname (default: 127.0.0.1)"); options.addOption("p", "port", true, "Server port (default: 3000)"); options.addOption("n", "namespace", true, "Namespace (default: test)"); options.addOption("s", "set", true, "Set (default: demo)"); options.addOption("u", "usage", false, "Print usage."); CommandLineParser parser = new PosixParser(); CommandLine cl = parser.parse(options, args, false); String host = cl.getOptionValue("h", "127.0.0.1"); String portString = cl.getOptionValue("p", "3000"); int port = Integer.parseInt(portString); String namespace = cl.getOptionValue("n", "test"); String set = cl.getOptionValue("s", "demo"); log.debug("Host: " + host); log.debug("Port: " + port); log.debug("Namespace: " + namespace); log.debug("Set: " + set); @SuppressWarnings("unchecked") List<String> cmds = cl.getArgList(); if (cmds.size() == 0 && cl.hasOption("u")) { logUsage(options); return; } AsACache as = new AsACache(host, port, namespace, set); as.work(); } catch (Exception e) { log.error("Critical error", e); } }
From source file:fr.inria.atlanmod.atl_mr.utils.NeoEMFHBaseMigrator.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input file, both of xmi and zxmi extensions are supported"); inputOpt.setArgs(1);/*from w w w .j a v a 2 s . c o m*/ inputOpt.setRequired(true); Option outputOpt = OptionBuilder.create(OUT); outputOpt.setArgName("OUTPUT"); outputOpt.setDescription("Output HBase resource URI"); outputOpt.setArgs(1); outputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(E_PACKAGE); inClassOpt.setArgName("METAMODEL"); inClassOpt.setDescription("URI of the ecore Metamodel"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); options.addOption(inputOpt); options.addOption(outputOpt); options.addOption(inClassOpt); CommandLineParser parser = new PosixParser(); try { CommandLine commandLine = parser.parse(options, args); URI sourceUri = URI.createFileURI(commandLine.getOptionValue(IN)); URI targetUri = URI.createURI(commandLine.getOptionValue(OUT)); URI metamodelUri = URI.createFileURI(commandLine.getOptionValue(E_PACKAGE)); NeoEMFHBaseMigrator.class.getClassLoader().loadClass(commandLine.getOptionValue(E_PACKAGE)) .getMethod("init").invoke(null); //org.eclipse.gmt.modisco.java.kyanos.impl.JavaPackageImpl.init(); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("zxmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put(KyanosURI.KYANOS_HBASE_SCHEME, KyanosResourceFactory.eINSTANCE); //Registering the metamodel // Resource MMResource = resourceSet.createResource(metamodelUri); // MMResource.load(Collections.EMPTY_MAP); // ATLMRUtils.registerPackages(resourceSet, MMResource); //Loading the XMI resource Resource sourceResource = resourceSet.createResource(sourceUri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if ("zxmi".equals(sourceUri.fileExtension())) { loadOpts.put(XMIResource.OPTION_ZIP, Boolean.TRUE); } Runtime.getRuntime().gc(); long initialUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory before loading: {0}", ATLMRUtils.byteCountToDisplaySize(initialUsedMemory))); LOG.log(Level.INFO, "Loading source resource"); sourceResource.load(loadOpts); LOG.log(Level.INFO, "Source resource loaded"); Runtime.getRuntime().gc(); long finalUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory after loading: {0}", ATLMRUtils.byteCountToDisplaySize(finalUsedMemory))); LOG.log(Level.INFO, MessageFormat.format("Memory use increase: {0}", ATLMRUtils.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory))); Resource targetResource = resourceSet.createResource(targetUri); Map<String, Object> saveOpts = new HashMap<String, Object>(); targetResource.save(saveOpts); LOG.log(Level.INFO, "Start moving elements"); targetResource.getContents().clear(); targetResource.getContents().addAll(sourceResource.getContents()); LOG.log(Level.INFO, "End moving elements"); LOG.log(Level.INFO, "Start saving"); targetResource.save(saveOpts); LOG.log(Level.INFO, "Saved"); if (targetResource instanceof KyanosHbaseResourceImpl) { KyanosHbaseResourceImpl.shutdownWithoutUnload((KyanosHbaseResourceImpl) targetResource); } else { targetResource.unload(); } } catch (ParseException e) { ATLMRUtils.showError(e.toString()); ATLMRUtils.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { ATLMRUtils.showError(e.toString()); e.printStackTrace(); } }
From source file:com.chigix.autosftp.Application.java
public static void main(String[] args) { Options options = new Options(); options.addOption(Option.builder("P").longOpt("port").hasArg().build()) .addOption(Option.builder("h").longOpt("help").desc("Print this message").build()) .addOption(Option.builder("i").argName("identity_file").hasArg().build()); int port = 22; CommandLine line;/* w ww.ja va2s . c o m*/ try { line = new DefaultParser().parse(options, args); } catch (UnrecognizedOptionException ex) { System.err.println(ex.getMessage()); return; } catch (ParseException ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); return; } if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("autosftp /path/to/watch [user@]host2:[file2]", options, true); return; } String givenPort; if (line.hasOption("port") && StringUtils.isNumeric(givenPort = line.getOptionValue("port"))) { port = Integer.valueOf(givenPort); } if (line.getArgs().length < 0) { System.err.println("Please provide a path to watch."); return; } localPath = Paths.get(line.getArgs()[0]); if (line.getArgs().length < 1) { System.err.println("Please provide remote ssh information."); return; } SshAddressParser addressParse; try { addressParse = new SshAddressParser().parse(line.getArgs()[1]); } catch (SshAddressParser.InvalidAddressException ex) { System.err.println(ex.getMessage()); return; } if (addressParse.getDefaultDirectory() != null) { remotePath = Paths.get(addressParse.getDefaultDirectory()); } try { sshSession = new JSch().getSession(addressParse.getUsername(), addressParse.getHost(), port); } catch (JSchException ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); return; } try { sshOpen(); } catch (JSchException ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); sshClose(); } System.out.println("Remote Default Path: " + remotePath); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { sshClose(); System.out.println("Bye~~~"); } }); try { watchDir(Paths.get(line.getArgs()[0])); } catch (Exception ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.leshazlewood.scms.cli.Main.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption(CONFIG).addOption(DEBUG).addOption(HELP).addOption(VERSION); boolean debug = false; File sourceDir = toFile(System.getProperty("user.dir")); File configFile = null;/* w w w. jav a 2s .co m*/ File destDir = null; try { CommandLine line = parser.parse(options, args); if (line.hasOption(VERSION.getOpt())) { printVersionAndExit(); } if (line.hasOption(HELP.getOpt())) { printHelpAndExit(options, null, debug, 0); } if (line.hasOption(DEBUG.getOpt())) { debug = true; } if (line.hasOption(CONFIG.getOpt())) { String configFilePath = line.getOptionValue(CONFIG.getOpt()); configFile = toFile(configFilePath); } String[] remainingArgs = line.getArgs(); if (remainingArgs == null) { printHelpAndExit(options, null, debug, -1); } assert remainingArgs != null; if (remainingArgs.length == 1) { String workingDirPath = System.getProperty("user.dir"); sourceDir = toFile(workingDirPath); destDir = toFile(remainingArgs[0]); } else if (remainingArgs.length == 2) { sourceDir = toFile(remainingArgs[0]); destDir = toFile((remainingArgs[1])); } else { printHelpAndExit(options, null, debug, -1); } assert sourceDir != null; assert destDir != null; if (configFile == null) { configFile = new File(sourceDir, DEFAULT_CONFIG_FILE_NAME); } if (configFile.exists()) { if (configFile.isDirectory()) { throw new IllegalArgumentException( "Expected configuration file " + configFile + " is a directory, not a file."); } } else { String msg = "Configuration file not found. Create a default " + DEFAULT_CONFIG_FILE_NAME + " file in your source directory or specify the " + CONFIG + " option to provide the file location."; throw new IllegalStateException(msg); } SiteExporter siteExporter = new SiteExporter(); siteExporter.setSourceDir(sourceDir); siteExporter.setDestDir(destDir); siteExporter.setConfigFile(configFile); siteExporter.init(); siteExporter.execute(); } catch (IllegalArgumentException iae) { exit(iae, debug); } catch (IllegalStateException ise) { exit(ise, debug); } catch (Exception e) { printHelpAndExit(options, e, debug, -1); } }
From source file:com.twitter.bazel.checkstyle.CppCheckstyle.java
public static void main(String[] args) throws IOException { CommandLineParser parser = new DefaultParser(); // create the Options Options options = new Options(); options.addOption(Option.builder("f").required(true).hasArg().longOpt("extra_action_file") .desc("bazel extra action protobuf file").build()); options.addOption(Option.builder("c").required(true).hasArg().longOpt("cpplint_file") .desc("Executable cpplint file to invoke").build()); try {//from w w w . java 2s . c o m // parse the command line arguments CommandLine line = parser.parse(options, args); String extraActionFile = line.getOptionValue("f"); String cpplintFile = line.getOptionValue("c"); Collection<String> sourceFiles = getSourceFiles(extraActionFile); if (sourceFiles.size() == 0) { LOG.fine("No cpp files found by checkstyle"); return; } LOG.fine(sourceFiles.size() + " cpp files found by checkstyle"); // Create and run the command List<String> commandBuilder = new ArrayList<>(); commandBuilder.add(cpplintFile); commandBuilder.add("--linelength=100"); // TODO: https://github.com/twitter/heron/issues/466, // Remove "runtime/references" when we fix all non-const references in our codebase. // TODO: https://github.com/twitter/heron/issues/467, // Remove "runtime/threadsafe_fn" when we fix all non-threadsafe libc functions commandBuilder.add("--filter=-build/header_guard,-runtime/references,-runtime/threadsafe_fn"); commandBuilder.addAll(sourceFiles); runLinter(commandBuilder); } catch (ParseException exp) { LOG.severe(String.format("Invalid input to %s: %s", CLASSNAME, exp.getMessage())); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java " + CLASSNAME, options); } }
From source file:MainServer.java
public static void main(String[] args) { int port = 1234; String filepath = ""; String complete_path = ""; String connection_type = ""; String ip_address = ""; int port_out = 0; int delay = 20; //20 by default //parse commands using getOpt (cli) //add Options Options options = new Options(); options.addOption("p", true, "port_to_listen_on"); options.addOption("d", true, "directory"); options.addOption("T", false, "TCP mode"); options.addOption("U", false, "UDP mode"); options.addOption("s", true, "iPAddress"); options.addOption("P", true, "port_to_connect_to"); options.addOption("D", true, "delay"); CommandLineParser clp = new DefaultParser(); try {/*from ww w . java2 s . c o m*/ CommandLine cl = clp.parse(options, args); //options for the server if (cl.hasOption("p")) { port = Integer.parseInt(cl.getOptionValue("p")); } else { System.err.println("No valid port selected."); return; } if (cl.hasOption("d")) { filepath = cl.getOptionValue("d"); //if there a '/' in front, remove it to make it a valid directory if (filepath.substring(0, 1).equalsIgnoreCase("/")) { filepath = filepath.substring(1); } } else { System.err.println("No valid directory given."); return; } if (cl.hasOption("D")) { delay = Integer.parseInt(cl.getOptionValue("D")); } //options for the client if (cl.hasOption("T")) { connection_type = "T"; } else if (cl.hasOption("U")) { connection_type = "U"; } if (cl.hasOption("s")) { ip_address = cl.getOptionValue("s"); } if (cl.hasOption("P")) { port_out = Integer.parseInt(cl.getOptionValue("P")); } } catch (ParseException e) { //TODO: handle exception } //create directory (if it doesn't already exist) try { Files.createDirectories(Paths.get(filepath)); } catch (Exception e) { //TODO: handle exception System.err.println("Couldn't create directory"); System.err.println(filepath); } //read in required files (create them if they dont already exist) try { Files.createFile(Paths.get(filepath + "/gossip.txt")); Files.createFile(Paths.get(filepath + "/peers.txt")); } catch (Exception e) { //TODO: handle exception } WriteToFiles.readFiles(filepath); //start the servers TCPServerSock tcpServer = new TCPServerSock(port, filepath, delay); UDPServer udpServer = new UDPServer(port, filepath); Thread tcpThread = new Thread(tcpServer); Thread udpThread = new Thread(udpServer); tcpThread.start(); udpThread.start(); //start the client if (!connection_type.equals("") && port_out != 0 && !ip_address.equals("")) { Client client = new Client(ip_address, port_out, connection_type); Thread clientThread = new Thread(client); clientThread.start(); } //Start thread to forget peers ForgetPeer forgetPeer = new ForgetPeer(filepath + "/peers.txt", delay); Thread forgetPeerThread = new Thread(forgetPeer); forgetPeerThread.start(); }
From source file:com.uber.tchannel.ping.PingClient.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "host", true, "Server Host to connect to"); options.addOption("p", "port", true, "Server Port to connect to"); options.addOption("n", "requests", true, "Number of requests to make"); options.addOption("?", "help", false, "Usage"); HelpFormatter formatter = new HelpFormatter(); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("?")) { formatter.printHelp("PingClient", options, true); return;// w ww .j av a2 s . c o m } String host = cmd.getOptionValue("h", "localhost"); int port = Integer.parseInt(cmd.getOptionValue("p", "8888")); int requests = Integer.parseInt(cmd.getOptionValue("n", "10000")); System.out.println(String.format("Connecting from client to server on port: %d", port)); new PingClient(host, port, requests).run(); System.out.println("Stopping Client..."); }
From source file:com.artistech.tuio.mouse.ZeroMqMouse.java
/** * Main entry point for ZeroMQ integration. * * @param args/*from w w w . j av a2 s . c o m*/ * @throws AWTException * @throws java.io.IOException */ public static void main(String[] args) throws AWTException, java.io.IOException { //read off the TUIO port from the command line String zeromq_port; Options options = new Options(); options.addOption("z", "zeromq-port", true, "ZeroMQ Server:Port to subscribe to. (-z localhost:5565)"); options.addOption("h", "help", false, "Show this message."); HelpFormatter formatter = new HelpFormatter(); try { CommandLineParser parser = new org.apache.commons.cli.BasicParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { formatter.printHelp("tuio-mouse-driver", options); return; } else { if (cmd.hasOption("z") || cmd.hasOption("zeromq-port")) { zeromq_port = cmd.getOptionValue("z"); } else { System.err.println("The zeromq-port value must be specified."); formatter.printHelp("tuio-mouse-driver", options); return; } } } catch (ParseException ex) { System.err.println("Error Processing Command Options:"); formatter.printHelp("tuio-mouse-driver", options); return; } //load conversion services ServiceLoader<ProtoConverter> services = ServiceLoader.load(ProtoConverter.class); //create zeromq context ZMQ.Context context = ZMQ.context(1); // Connect our subscriber socket ZMQ.Socket subscriber = context.socket(ZMQ.SUB); subscriber.setIdentity(ZeroMqMouse.class.getName().getBytes()); //this could change I guess so we can get different data subscrptions. subscriber.subscribe("TuioCursor".getBytes()); // subscriber.subscribe("TuioTime".getBytes()); subscriber.connect("tcp://" + zeromq_port); System.out.println("Subscribed to " + zeromq_port + " for ZeroMQ messages."); // Get updates, expect random Ctrl-C death String msg = ""; MouseDriver md = new MouseDriver(); while (!msg.equalsIgnoreCase("END")) { boolean success = false; byte[] recv = subscriber.recv(); com.google.protobuf.GeneratedMessage message = null; TuioPoint pt = null; String type = recv.length > 0 ? new String(recv) : ""; recv = subscriber.recv(); switch (type) { case "TuioCursor.PROTOBUF": try { //it is a cursor? message = com.artistech.protobuf.TuioProtos.Cursor.parseFrom(recv); success = true; } catch (Exception ex) { } break; case "TuioTime.PROTOBUF": // try { // //it is a cursor? // message = com.artistech.protobuf.TuioProtos.Time.parseFrom(recv); // success = true; // } catch (Exception ex) { // } break; case "TuioObject.PROTOBUF": try { //it is a cursor? message = com.artistech.protobuf.TuioProtos.Object.parseFrom(recv); success = true; } catch (Exception ex) { } break; case "TuioBlob.PROTOBUF": try { //it is a cursor? message = com.artistech.protobuf.TuioProtos.Blob.parseFrom(recv); success = true; } catch (Exception ex) { } break; case "TuioCursor.JSON": try { //it is a cursor? pt = mapper.readValue(recv, TUIO.TuioCursor.class); success = true; } catch (Exception ex) { } break; case "TuioTime.JSON": // try { // //it is a cursor? // pt = mapper.readValue(recv, TUIO.TuioTime.class); // success = true; // } catch (Exception ex) { // } break; case "TuioObject.JSON": try { //it is a cursor? pt = mapper.readValue(recv, TUIO.TuioObject.class); success = true; } catch (Exception ex) { } break; case "TuioBlob.JSON": try { //it is a cursor? pt = mapper.readValue(recv, TUIO.TuioBlob.class); success = true; } catch (Exception ex) { } break; case "TuioTime.OBJECT": break; case "TuioCursor.OBJECT": case "TuioObject.OBJECT": case "TuioBlob.OBJECT": try { //Try reading the data as a serialized Java object: try (ByteArrayInputStream bis = new ByteArrayInputStream(recv)) { //Try reading the data as a serialized Java object: ObjectInput in = new ObjectInputStream(bis); Object o = in.readObject(); //if it is of type Point (Cursor, Object, Blob), process: if (TuioPoint.class.isAssignableFrom(o.getClass())) { pt = (TuioPoint) o; process(pt, md); } success = true; } } catch (java.io.IOException | ClassNotFoundException ex) { } finally { } break; default: success = false; break; } if (message != null && success) { //ok, so we have a message that is not null, so it was protobuf: Object o = null; //look for a converter that will suppor this objec type and convert: for (ProtoConverter converter : services) { if (converter.supportsConversion(message)) { o = converter.convertFromProtobuf(message); break; } } //if the type is of type Point (Cursor, Blob, Object), process: if (o != null && TuioPoint.class.isAssignableFrom(o.getClass())) { pt = (TuioPoint) o; } } if (pt != null) { process(pt, md); } } }
From source file:com.datastax.sparql.ConsoleCompiler.java
public static void main(final String[] args) throws IOException { //args = "/examples/modern1.sparql"; final Options options = new Options(); options.addOption("f", "file", true, "a file that contains a SPARQL query"); options.addOption("g", "graph", true, "the graph that's used to execute the query [classic|modern|crew|kryo file]"); // TODO: add an OLAP option (perhaps: "--olap spark"?) final CommandLineParser parser = new DefaultParser(); final CommandLine commandLine; try {//from ww w. j a va 2s . co m commandLine = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); printHelp(1); return; } final InputStream inputStream = commandLine.hasOption("file") ? new FileInputStream(commandLine.getOptionValue("file")) : System.in; final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); final StringBuilder queryBuilder = new StringBuilder(); if (!reader.ready()) { printHelp(1); } String line; while (null != (line = reader.readLine())) { queryBuilder.append(System.lineSeparator()).append(line); } final String queryString = queryBuilder.toString(); final Graph graph; if (commandLine.hasOption("graph")) { switch (commandLine.getOptionValue("graph").toLowerCase()) { case "classic": graph = TinkerFactory.createClassic(); break; case "modern": graph = TinkerFactory.createModern(); System.out.println("Modern Graph Created"); break; case "crew": graph = TinkerFactory.createTheCrew(); break; default: graph = TinkerGraph.open(); System.out.println("Graph Created"); long startTime = System.nanoTime(); graph.io(IoCore.gryo()).readGraph(commandLine.getOptionValue("graph")); long endTime = System.nanoTime(); System.out.println("Time taken to load graph from kyro file: " + (endTime - startTime) / 1000000 + " mili seconds"); break; } } else { graph = TinkerFactory.createModern(); } final Traversal<Vertex, ?> traversal = SparqlToGremlinCompiler.convertToGremlinTraversal(graph, queryString); printWithHeadline("SPARQL Query", queryString); printWithHeadline("Traversal (prior execution)", traversal); Bytecode traversalByteCode = traversal.asAdmin().getBytecode(); //JavaTranslator.of(graph.traversal()).translate(traversalByteCode); System.out.println("the Byte Code : " + traversalByteCode.toString()); printWithHeadline("Result", String.join(System.lineSeparator(), JavaTranslator.of(graph.traversal()) .translate(traversalByteCode).toStream().map(Object::toString).collect(Collectors.toList()))); printWithHeadline("Traversal (after execution)", traversal); }
From source file:com.github.trohovsky.jira.analyzer.Main.java
public static void main(String[] args) throws Exception { final Options options = new Options(); options.addOption("u", true, "username"); options.addOption("p", true, "password (optional, if not provided, the password is prompted)"); options.addOption("h", false, "show this help"); options.addOption("s", true, "use the strategy for querying and output, the strategy can be either 'issues_toatal' (default) or" + " 'per_month'"); options.addOption("d", true, "CSV delimiter"); // parsing of the command line arguments final CommandLineParser parser = new DefaultParser(); CommandLine cmdLine = null;/* w w w. j a va2 s. c o m*/ try { cmdLine = parser.parse(options, args); if (cmdLine.hasOption('h') || cmdLine.getArgs().length == 0) { final HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(null); formatter.printHelp(HELP_CMDLINE, HELP_HEADER, options, null); return; } if (cmdLine.getArgs().length != 3) { throw new ParseException("You should specify exactly three arguments JIRA_SERVER JQL_QUERY_TEMPLATE" + " PATH_TO_PARAMETER_FILE"); } } catch (ParseException e) { System.err.println("Error parsing command line: " + e.getMessage()); final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(HELP_CMDLINE, HELP_HEADER, options, null); return; } final String csvDelimiter = (String) (cmdLine.getOptionValue('d') != null ? cmdLine.getOptionObject('d') : CSV_DELIMITER); final URI jiraServerUri = URI.create(cmdLine.getArgs()[0]); final String jqlQueryTemplate = cmdLine.getArgs()[1]; final List<List<String>> queryParametersData = readCSVFile(cmdLine.getArgs()[2], csvDelimiter); final String username = cmdLine.getOptionValue("u"); String password = cmdLine.getOptionValue("p"); final String strategy = cmdLine.getOptionValue("s"); try { // initialization of the REST client final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); if (username != null) { if (password == null) { final Console console = System.console(); final char[] passwordCharacters = console.readPassword("Password: "); password = new String(passwordCharacters); } restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, username, password); } else { restClient = factory.create(jiraServerUri, new AnonymousAuthenticationHandler()); } final SearchRestClient searchRestClient = restClient.getSearchClient(); // choosing of an analyzer strategy AnalyzerStrategy analyzer = null; if (strategy != null) { switch (strategy) { case "issues_total": analyzer = new IssuesTotalStrategy(searchRestClient); break; case "issues_per_month": analyzer = new IssuesPerMonthStrategy(searchRestClient); break; default: System.err.println("The strategy does not exist"); return; } } else { analyzer = new IssuesTotalStrategy(searchRestClient); } // analyzing for (List<String> queryParameters : queryParametersData) { analyzer.analyze(jqlQueryTemplate, queryParameters); } } finally { // destroy the REST client, otherwise it stucks restClient.close(); } }