List of usage examples for org.apache.commons.cli Options addOption
public Options addOption(String opt, String longOpt, boolean hasArg, String description)
From source file:io.github.tigertoes.DependencyMonkey.java
/** * @param args String//from www. ja v a 2 s . c o m */ public static void main(String[] args) { Options options = new Options(); options.addOption("v", "verbose", false, "Verbose mode"); options.addOption("p", "pom-file", true, "Path to pom.xml"); }
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 {// www . ja v a 2 s . c o m 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.rapleaf.hank.cli.AddDomainGroup.java
public static void main(String args[]) throws InterruptedException, IOException, ParseException, InvalidConfigurationException { Options options = new Options(); options.addOption("n", "name", true, "the name of the domain to be created"); options.addOption("c", "config", true, "path of a valid config file with coordinator connection information"); try {/*w w w . j av a 2 s. c o m*/ CommandLine line = new GnuParser().parse(options, args); CommandLineChecker.check(line, options, new String[] { "config", "name" }, AddDomainGroup.class); ClientConfigurator configurator = new YamlClientConfigurator(line.getOptionValue("config")); addDomainGroup(configurator, line.getOptionValue("name")); } catch (ParseException e) { new HelpFormatter().printHelp("add_domain", options); throw e; } }
From source file:com.google.api.codegen.config.ConfigGeneratorTool.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "show usage"); options.addOption(Option.builder().longOpt("descriptor_set") .desc("The descriptor set representing the compiled input protos.").hasArg() .argName("DESCRIPTOR-SET").required(true).build()); options.addOption(/*from w w w . ja va2s.co m*/ Option.builder("o").longOpt("output").desc("The directory in which to output the generated config.") .hasArg().argName("OUTPUT-FILE").required(true).build()); CommandLine cl = (new DefaultParser()).parse(options, args); if (cl.hasOption("help")) { HelpFormatter formater = new HelpFormatter(); formater.printHelp("ConfigGeneratorTool", options); } generate(cl.getOptionValue("descriptor_set"), cl.getOptionValue("output")); }
From source file:com.rapleaf.hank.cli.AddRingGroup.java
public static void main(String[] args) throws IOException, ParseException, InvalidConfigurationException { Options options = new Options(); options.addOption("r", "ring-group", true, "the name of the ring group to be created"); options.addOption("d", "domain-group", true, "the name of the domain group that this ring group will be linked to"); options.addOption("c", "config", true, "path of a valid config file with coordinator connection information"); try {/*from w ww. jav a2 s . co m*/ CommandLine line = new GnuParser().parse(options, args); CommandLineChecker.check(line, options, new String[] { "config", "ring-group", "domain-group" }, AddRingGroup.class); ClientConfigurator configurator = new YamlClientConfigurator(line.getOptionValue("config")); addRingGroup(configurator, line.getOptionValue("ring-group"), line.getOptionValue("domain-group")); } catch (ParseException e) { new HelpFormatter().printHelp("add_domain", options); throw e; } }
From source file:eu.scape_project.sanselan_wrapper.SanselanCli.java
public static void main(String[] args) { try {//w w w .ja v a 2 s. co m 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;//www. j a v a 2s . com } 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.google.api.codegen.configgen.ConfigGeneratorTool.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "show usage"); options.addOption(Option.builder().longOpt("descriptor_set") .desc("The descriptor set representing the compiled input protos.").hasArg() .argName("DESCRIPTOR-SET").required(true).build()); options.addOption(// ww w .j av a 2 s .c o m Option.builder().longOpt("service_yaml").desc("The service YAML configuration file or files.") .hasArg().argName("SERVICE-YAML").required(true).build()); options.addOption( Option.builder("o").longOpt("output").desc("The directory in which to output the generated config.") .hasArg().argName("OUTPUT-FILE").required(true).build()); CommandLine cl = (new DefaultParser()).parse(options, args); if (cl.hasOption("help")) { HelpFormatter formater = new HelpFormatter(); formater.printHelp("ConfigGeneratorTool", options); } generate(cl.getOptionValue("descriptor_set"), cl.getOptionValues("service_yaml"), cl.getOptionValue("output")); }
From source file:io.stpettersen.bluejpackager.BlueJPackager.java
public static void main(String[] args) { // Create the command line parser. CommandLineParser parser = new DefaultParser(); // Create the command line options. Options options = new Options(); options.addOption("h", "help", false, "Display this help information and exit."); options.addOption("v", "version", false, "Display version information and exit."); options.addOption("p", "package", true, "Package string to use."); options.addOption("m", "mainClass", true, "Main class to use."); options.addOption("cp", "classPath", true, "Class path directory."); options.addOption("r", "root", true, "Root directory."); options.addOption("l", "verbose", false, "Be verbose."); try {// w w w. jav a 2 s. c om // Parse the command line arguments. CommandLine cli = parser.parse(options, args); if (cli.hasOption("h")) displayUsage(options, 0); } catch (Exception e) { // Bad command line option occurred. System.err.println("\nError: " + e.getMessage()); displayUsage(options, 1); } }
From source file:com.google.cloud.trace.v1.TraceServiceSmokeTest.java
public static void main(String args[]) { Logger.getLogger("").setLevel(Level.WARNING); try {/*from ww w. j a v a 2s .c om*/ Options options = new Options(); options.addOption("h", "help", false, "show usage"); options.addOption(Option.builder().longOpt("project_id").desc("Project id").hasArg() .argName("PROJECT-ID").required(true).build()); CommandLine cl = (new DefaultParser()).parse(options, args); if (cl.hasOption("help")) { HelpFormatter formater = new HelpFormatter(); formater.printHelp("TraceServiceSmokeTest", options); } executeNoCatch(cl.getOptionValue("project_id")); System.out.println("OK"); } catch (Exception e) { System.err.println("Failed with exception:"); e.printStackTrace(System.err); System.exit(1); } }