List of usage examples for org.apache.commons.cli Option Option
public Option(String opt, boolean hasArg, String description) throws IllegalArgumentException
From source file:ch.ethz.topobench.graph.utility.CmdAssistant.java
/** * Add a required option to the options with the given name and description. * * @param options Options set for the command line * @param arg Argument name (- variant) * @param desc Description//from w ww.j av a2 s . c o m */ public static void addOption(Options options, String arg, String desc) { Option opt = new Option(arg, true, desc); opt.setRequired(true); options.addOption(opt); }
From source file:de.topobyte.utilities.apache.commons.cli.OptionHelper.java
/** * Add a short option to the options specified by parameters * //from ww w . j a v a 2 s.co m * @param options * the options to add to. * @param opt * the short option name. * @param hasArg * whether it expects an argument * @param required * whether this is a required option. * @param description * the option description * @return the Option object created. */ public static Option addS(Options options, String opt, boolean hasArg, boolean required, String description) { Option option = new Option(opt, hasArg, description); option.setRequired(required); options.addOption(option); return option; }
From source file:com.spectralogic.autogen.cli.CLI.java
private CLI() { this.options = new Options(); final Option language = new Option("l", true, "Select the language to generate"); final Option directory = new Option("d", true, "Directory to write generated code to"); final Option inputSpec = new Option("i", true, "The spec file for the DS3 API"); final Option help = new Option("h", false, "Print usage"); final Option generateInternal = new Option("internal", false, "Generate Spectra Internal requests"); final Option noDoc = new Option(null, false, "Generate with no documentation"); noDoc.setLongOpt("no-doc"); options.addOption(language);//from w w w. ja va 2 s . com options.addOption(directory); options.addOption(inputSpec); options.addOption(help); options.addOption(generateInternal); options.addOption(noDoc); }
From source file:com.genentech.chemistry.tool.SDFBinning.java
private static void processOptions(String[] args) { Options options = new Options(); Option opt = new Option("in", true, "Input file oe-supported Use .sdf to specify the file type."); opt.setRequired(true);//from w ww. j a v a2s . c o m options.addOption(opt); opt = new Option("out", true, "Output file oe-supported Use .sdf to specify the file type."); opt.setRequired(true); options.addOption(opt); opt = new Option("bin", true, "bin definition. Use format \"bin_1_upperbound=bin_1_name|bin_2_upperbound=bin_2_name|bin_3_upperbound_=bin_3_name\""); opt.setRequired(true); options.addOption(opt); opt = new Option("dataTag", true, "SD tag containing data for binning"); opt.setRequired(true); options.addOption(opt); opt = new Option("binTag", true, "SD tag used for storing bin names"); opt.setRequired(true); options.addOption(opt); opt = new Option("ignoreModifier", false, "ignore leading '><= ~'"); options.addOption(opt); opt = new Option("h", false, "print usage statement"); opt.setRequired(false); options.addOption(opt); PosixParser parser = new PosixParser(); CommandLine cl = null; try { cl = parser.parse(options, args); } catch (Exception exp) { // catch (ParseException exp) { System.err.println(exp.getMessage()); exitWithHelp(options); } inFile = cl.getOptionValue("in"); outFile = cl.getOptionValue("out"); ignoreModifier = cl.hasOption("ignoreModifier"); String binDefinition = cl.getOptionValue("bin"); parseBins(binDefinition); binTag = cl.getOptionValue("binTag"); dataTag = cl.getOptionValue("dataTag"); }
From source file:com.spectralogic.ds3contractcomparator.cli.CLI.java
private CLI() { this.options = new Options(); final Option oldSpec = new Option("o", true, "The spec file for the older version of the DS3 API"); final Option newSpec = new Option("n", true, "The spec file for the newer version of the DS3 API"); final Option outFile = new Option("d", true, "The file name for the output of the comparison"); final Option help = new Option("h", false, "Print usage"); final Option properties = new Option(null, false, "Prints EnumConstant Properties which are excluded by default"); properties.setLongOpt("properties"); final Option annotations = new Option(null, false, "Prints all Element Annotations instead of filtering out less used annotations by default"); annotations.setLongOpt("annotations"); final Option printer = new Option("p", true, "Specify report printer: " + PrinterType.valuesString()); options.addOption(oldSpec);// ww w . ja va 2 s. c om options.addOption(newSpec); options.addOption(outFile); options.addOption(help); options.addOption(properties); options.addOption(annotations); options.addOption(printer); }
From source file:au.id.hazelwood.xmltvguidebuilder.runner.Main.java
private static Option createOptionWithArg(String opt, boolean required, String argName, Class<?> argType, String description) {//w w w .j av a 2s. c o m Option option = new Option(opt, true, description); option.setRequired(required); option.setArgName(argName); option.setType(argType); return option; }
From source file:com.netscape.cmstools.OCSPClient.java
public static Options createOptions() throws UnknownHostException { Options options = new Options(); Option option = new Option("d", true, "Security database location (default: current directory)"); option.setArgName("database"); options.addOption(option);//from ww w . j ava 2 s .c om option = new Option("h", true, "OCSP server hostname (default: " + InetAddress.getLocalHost().getCanonicalHostName() + ")"); option.setArgName("hostname"); options.addOption(option); option = new Option("p", true, "OCSP server port number (default: 8080)"); option.setArgName("port"); options.addOption(option); option = new Option("t", true, "OCSP service path (default: /ocsp/ee/ocsp)"); option.setArgName("path"); options.addOption(option); option = new Option("c", true, "CA certificate nickname (default: CA Signing Certificate)"); option.setArgName("nickname"); options.addOption(option); option = new Option("n", true, "Number of submissions (default: 1)"); option.setArgName("times"); options.addOption(option); option = new Option(null, "serial", true, "Serial number of certificate to be checked"); option.setArgName("serial"); options.addOption(option); option = new Option(null, "input", true, "Input file containing DER-encoded OCSP request"); option.setArgName("input"); options.addOption(option); option = new Option(null, "output", true, "Output file to store DER-encoded OCSP response"); option.setArgName("output"); options.addOption(option); options.addOption("v", "verbose", false, "Run in verbose mode."); options.addOption(null, "help", false, "Show help message."); return options; }
From source file:com.taobao.metamorphosis.server.MetamorphosisStartup.java
static String getConfigFilePath(final String[] args) throws MetamorphosisServerStartupException { final Options options = new Options(); final Option file = new Option("f", true, "Configuration file path"); options.addOption(file);//from w ww.jav a 2s . c o m final CommandLineParser parser = new PosixParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (final ParseException e) { throw new MetamorphosisServerStartupException("Parse command line failed", e); } String configFilePath = null; if (line.hasOption("f")) { configFilePath = line.getOptionValue("f"); } else { System.err.println("Please tell me the configuration file path by -f option"); System.exit(1); } if (StringUtils.isBlank(configFilePath)) { throw new MetamorphosisServerStartupException("Blank file path"); } return configFilePath; }
From source file:edu.vt.middleware.ldap.cli.DeleteOperationCli.java
/** {@inheritDoc} */ @Override/*from w w w .ja v a 2s .co m*/ protected void initOptions() { options.addOption(new Option(OPT_DN, true, "entry DN")); final Map<String, String> desc = getArgDesc(ConnectionConfig.class); for (String s : ConnectionConfigPropertySource.getProperties()) { options.addOption(new Option(s, true, desc.get(s))); } super.initOptions(); }
From source file:com.aliyun.openservices.odps.console.pub.StopInstanceCommand.java
static Options initOptions() { Options opts = new Options(); Option synchronizeFlag = new Option("sync", true, "synchronizeFlag"); synchronizeFlag.setRequired(false);// w w w .j ava 2 s . c o m opts.addOption(synchronizeFlag); return opts; }