List of usage examples for org.apache.commons.cli CommandLineParser parse
CommandLine parse(Options options, String[] arguments) throws ParseException;
From source file:com.chriscx.similarity.SimilarityApp.java
public static void main(String[] args) throws ParseException { Options options = new Options(); options.addOption("i", true, "input folder"); options.addOption("o", true, "output folder"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (args.length > 1) { }//w w w . j a v a2 s .co m }
From source file:ant_ivy.Hello.java
public static void main(String[] args) throws Exception { Option msg = OptionBuilder.withArgName("msg").hasArg().withDescription("the message to capitalize") .create("message"); Options options = new Options(); options.addOption(msg);/* w ww. ja va 2 s .c o m*/ CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); String message = line.getOptionValue("message", "hello ivy !"); System.out.println("standard message : " + message); System.out.println( "capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message)); }
From source file:example.HelloConsole.java
public static void main(String[] args) throws Exception { Option msg = Option.builder("m").longOpt("message").hasArg().desc("the message to capitalize").build(); Options options = new Options(); options.addOption(msg);/*w w w .j a v a2 s .co m*/ CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); String message = line.getOptionValue("m", "Hello Ivy!"); System.out.println("standard message : " + message); System.out.println( "capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message)); }
From source file:eu.scape_project.sanselan_wrapper.SanselanCli.java
public static void main(String[] args) { try {//w w w . j a v a 2s.c om Options options = new Options(); options.addOption("i", "input-file", true, "input file"); options.addOption("o", "output-file", true, "output file"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("i") && cmd.hasOption("o")) { BufferedImage inImage = SanselanWrapper.load(cmd.getOptionValue("i"), null); SanselanWrapper.convert(inImage, cmd.getOptionValue("o"), null); } else { System.out.println("usage: (-i|--input-file=) INPUT_FILE (-o|--output-file=) OUTPUT_FILE"); System.exit(1); } } catch (Exception e) { System.err.println(e); System.exit(1); } System.exit(0); }
From source file:it.anyplace.sync.relay.server.Main.java
public static void main(String[] args) throws ParseException, Exception { Options options = new Options(); options.addOption("r", "relay-server", true, "set relay server to serve for"); options.addOption("p", "port", true, "set http server port"); options.addOption("h", "help", false, "print help"); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("s-client", options); return;/*w w w .ja v a 2 s . c o m*/ } int port = cmd.hasOption("p") ? Integer.parseInt(cmd.getOptionValue("p")) : 22080; String relayServer = firstNonNull(emptyToNull(cmd.getOptionValue("r")), "relay://localhost"); logger.info("starting http relay server :{} for relay server {}", port, relayServer); HttpRelayServer httpRelayServer = new HttpRelayServer( DeviceAddress.newBuilder().setDeviceId("relay").setAddress(relayServer).build().getSocketAddress()); httpRelayServer.start(port); httpRelayServer.join(); }
From source file:com.opensearchserver.textextractor.Main.java
public static void main(String[] args) throws IOException, ParseException { Logger.getLogger("").setLevel(Level.WARNING); Options options = new Options(); options.addOption("h", "help", false, "print this message"); options.addOption("p", "port", true, "TCP port"); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar target/oss-text-extractor.jar", options); return;//from w w w.j a v a 2s . co m } int port = cmd.hasOption("p") ? Integer.parseInt(cmd.getOptionValue("p")) : 9091; UndertowJaxrsServer server = new UndertowJaxrsServer() .start(Undertow.builder().addHttpListener(port, "localhost")); server.deploy(Main.class); }
From source file:au.id.hazelwood.xmltvguidebuilder.runner.Main.java
public static void main(String[] args) throws Exception { SLF4JBridgeHandler.install();//from www . j a v a 2 s.c o m Options options = new Options(); options.addOption(createOptionWithArg("config", true, "file", File.class, "Config file location")); options.addOption(createOptionWithArg("out", true, "file", File.class, "Output file name")); try { CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); App app = new App(); app.run((File) line.getParsedOptionValue("config"), (File) line.getParsedOptionValue("out")); } catch (ParseException exp) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Main", options, true); } }
From source file:com.huangyunkun.jviff.Runner.java
public static void main(String args[]) { Options options = new Options(); options.addOption("c", "config", true, "config file"); CommandLineParser parser = new PosixParser(); try {/* w w w . j a va 2 s.com*/ CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("c")) { JViff jViff = new JViff(cmd.getOptionValue("c")); jViff.run(); } else { printHelp(options); } } catch (ParseException e) { printHelp(options); } catch (IOException e) { LOGGER.error("jviff face a error", e); } }
From source file:com.ibm.rdf.store.sparql11.DB2RDFQuery.java
public static void main(String[] args) { Options options = new Options(); try {/* www.j a v a2 s. co m*/ // create Options object options.addOption("jdbcurl", true, "jdbc url"); options.addOption("schema", true, "schema name"); options.addOption("kb", true, "knowledge base"); options.addOption("username", true, "db user name"); options.addOption("password", true, "db password"); options.addOption("queryFile", true, "query file"); options.addOption("defaultUnionGraph", false, "default Union Graph semantics"); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); boolean defUnion = cmd.hasOption("defaultUnionGraph") ? Boolean.parseBoolean(cmd.getOptionValue("defaultUnionGraph")) : false; DB2TestData data = new DB2TestData(cmd.getOptionValue("jdbcurl"), cmd.getOptionValue("kb"), cmd.getOptionValue("username"), cmd.getOptionValue("password"), cmd.getOptionValue("schemaName"), defUnion); DB2RDFQuery q = new DB2RDFQuery(new DB2Engine(), data); q.executeQuery(cmd.getOptionValue("queryFile")); } catch (Exception e) { e.printStackTrace(); HelpFormatter help = new HelpFormatter(); help.printHelp("DB2RDFQuery", options); } }
From source file:de.drippinger.cytricHelper.CommandLineStart.java
public static void main(String[] args) throws ParseException { CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(createOptions(), args); CytricHelper helper = new CytricHelper(); if (cmd.hasOption("f") && cmd.hasOption("e")) { try {//from w w w . ja v a2 s.c o m helper.manipulatePdf(cmd.getOptionValue("f"), cmd.getOptionValue("e")); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } else { printHelp(); } }