List of usage examples for org.apache.commons.cli Option Option
public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException
From source file:com.netscape.cmstools.pkcs12.PKCS12CertExportCLI.java
public void createOptions() { Option option = new Option(null, "pkcs12-file", true, "PKCS #12 file"); option.setArgName("path"); options.addOption(option);/* ww w .j ava 2 s . c o m*/ option = new Option(null, "pkcs12-password", true, "PKCS #12 password"); option.setArgName("password"); options.addOption(option); option = new Option(null, "pkcs12-password-file", true, "PKCS #12 password file"); option.setArgName("path"); options.addOption(option); option = new Option(null, "cert-file", true, "Certificate file"); option.setArgName("path"); options.addOption(option); option = new Option(null, "cert-id", true, "Certificate ID to export"); option.setArgName("ID"); options.addOption(option); options.addOption("v", "verbose", false, "Run in verbose mode."); options.addOption(null, "debug", false, "Run in debug mode."); options.addOption(null, "help", false, "Show help message."); }
From source file:net.sf.markov4jmeter.behaviormodelextractor.CmdlOptionFactory.java
/** * Creates an option with a specified number of arguments; * * @param opt// w ww . j av a2 s . co m * Short representation of the option (e.g. <code>"s"</code>). * @param longOpt * Long representation of the option * (e.g. <code>"source-project"</code>). * @param description * Description of the option * (e.g. <code>"Path to source project."</code>). * @param isRequired * Flag indicating whether the option is required (as a command-line * argument) or not. * @param argName * Display name for the argument value. * @param argsNum * Number of arguments; a negative value indicates an infinite sequence * of arguments. * @param hasOptionalArg * <code>true</code> if and only if the arguments are optional. * @return * An instance of {@link Option} with the specified properties. */ public static Option createOption(final String opt, final String longOpt, final String description, final boolean isRequired, final String argName, final int argsNum, final boolean hasOptionalArg) { final Option option = new Option(opt, longOpt, argsNum != 0 /* hasArg */, description); option.setRequired(isRequired); if (argsNum != 0) { // argsNum < 0 for infinite sequence of arguments; if (argName != null) { option.setArgName(argName); } // negative number of arguments implies an infinite sequence; option.setArgs((argsNum < 0) ? Integer.MAX_VALUE : argsNum); option.setValueSeparator(CmdlOptionFactory.DEFAULT_VALUE_SEPARATOR); option.setOptionalArg(hasOptionalArg); } return option; }
From source file:com.cloudera.beeswax.Server.java
/** * Parse command line options./*w w w . j av a2 s .c o m*/ * * -b <port> specifies the port for beeswax to use. * -m <port>, if given, starts the metastore at this port. */ private static void parseArgs(String[] args) throws ParseException { Options options = new Options(); Option metastoreOpt = new Option("m", "metastore", true, "port to use for metastore"); metastoreOpt.setRequired(false); options.addOption(metastoreOpt); Option beeswaxOpt = new Option("b", "beeswax", true, "port to use for beeswax"); beeswaxOpt.setRequired(true); options.addOption(beeswaxOpt); Option dtHostOpt = new Option("h", "desktop-host", true, "host running desktop"); dtHostOpt.setRequired(true); options.addOption(dtHostOpt); Option dtHttpsOpt = new Option("s", "desktop-https", true, "desktop is running https"); options.addOption(dtHttpsOpt); Option dtPortOpt = new Option("p", "desktop-port", true, "port used by desktop"); dtPortOpt.setRequired(true); options.addOption(dtPortOpt); Option superUserOpt = new Option("u", "superuser", true, "Username of Hadoop superuser (default: hadoop)"); superUserOpt.setRequired(false); options.addOption(superUserOpt); PosixParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (!cmd.getArgList().isEmpty()) { throw new ParseException("Unexpected extra arguments: " + cmd.getArgList()); } for (Option opt : cmd.getOptions()) { if (opt.getOpt() == "m") { mport = parsePort(opt); } else if (opt.getOpt() == "b") { bport = parsePort(opt); } else if (opt.getOpt() == "u") { superUser = opt.getValue(); } else if (opt.getOpt() == "h") { dtHost = opt.getValue(); } else if (opt.getOpt() == "p") { dtPort = parsePort(opt); } else if (opt.getOpt() == "s") { dtHttps = true; } } }
From source file:com.alibaba.rocketmq.tools.command.broker.GetBrokerConfigCommand.java
@Override public Options buildCommandlineOptions(final Options options) { Option opt = new Option("b", "brokerAddr", true, "update which broker"); opt.setRequired(false);/* w w w . j a v a 2s . c o m*/ options.addOption(opt); opt = new Option("c", "clusterName", true, "update which cluster"); opt.setRequired(false); options.addOption(opt); return options; }
From source file:galen.api.server.GalenApiServer.java
private static Options defineCommandOptions() { Option helpOption = new Option("help", "h", false, "explains usage"); Option runOption = OptionBuilder.hasArg().withArgName("port") .withDescription("Runs the server on specified port").withLongOpt("r").create("run"); Options options = new Options(); options.addOption(helpOption).addOption(runOption); return options; }
From source file:de.uni_koblenz.jgralab.utilities.tg2schemagraph.Tg2SchemaGraph.java
private static CommandLine processCommandLineOptions(String[] args) { String toolString = "java " + Tg2SchemaGraph.class.getName(); String versionString = JGraLab.getInfo(false); OptionHandler oh = new OptionHandler(toolString, versionString); Option output = new Option("o", "output", true, "(required): the output file name"); output.setRequired(true);/*from w ww. j a va 2s.c om*/ output.setArgName("file"); oh.addOption(output); Option schema = new Option("s", "schema", true, "(required): the schema of which a schemaGraph should be generated"); schema.setRequired(true); schema.setArgName("file"); oh.addOption(schema); return oh.parse(args); }
From source file:com.alibaba.rocketmq.tools.command.topic.TopicListSubCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("c", "clusterModel", false, "clusterModel"); opt.setRequired(false);/*from ww w .j av a 2s. c om*/ options.addOption(opt); return options; }
From source file:com.alibaba.rocketmq.tools.command.cluster.ClusterListSubCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("m", "moreStats", false, "Print more stats"); opt.setRequired(false);/* w w w . ja va 2 s.com*/ options.addOption(opt); return options; }
From source file:de.mat.utils.pdftools.PdfResize.java
@Override protected Options genAvailiableCmdLineOptions() throws Throwable { Options availiableCmdLineOptions = new Options(); // Hilfe-Option Option helpOption = new Option("h", "help", false, "usage"); helpOption.setRequired(false);/*www.j a v a 2 s .c om*/ availiableCmdLineOptions.addOption(helpOption); Option inFile = new Option("i", "in", true, "Input-File"); inFile.setRequired(true); availiableCmdLineOptions.addOption(inFile); Option outFile = new Option("o", "out", true, "Outputfile"); outFile.setRequired(true); availiableCmdLineOptions.addOption(outFile); Option factorX = new Option("x", "scalex", true, "Scalierung-X"); factorX.setRequired(true); availiableCmdLineOptions.addOption(factorX); Option factorY = new Option("y", "scaley", true, "Scalierung-Y"); factorY.setRequired(true); availiableCmdLineOptions.addOption(factorY); Option offsetL = new Option("l", "offsetleft", true, "Offset-Left"); offsetL.setRequired(true); availiableCmdLineOptions.addOption(offsetL); Option offsetT = new Option("t", "offsettop", true, "Offset-Top"); offsetT.setRequired(true); availiableCmdLineOptions.addOption(offsetT); return availiableCmdLineOptions; }
From source file:com.opengamma.bloombergexample.loader.PortfolioLoaderHelper.java
/** * Builds the set of options.// w ww. j av a 2 s . c o m * * @param options the options to add to, not null */ public static void buildOptions(Options options) { Option filenameOption = new Option(FILE_NAME_OPT, "filename", true, "The path to the CSV file of cash details"); filenameOption.setRequired(true); options.addOption(filenameOption); Option portfolioNameOption = new Option(PORTFOLIO_NAME_OPT, "name", true, "The name of the portfolio"); portfolioNameOption.setRequired(true); options.addOption(portfolioNameOption); // Option runModeOption = new Option(RUN_MODE_OPT, "runmode", true, "The run mode: shareddev, standalone"); // runModeOption.setRequired(true); // options.addOption(runModeOption); Option writeOption = new Option(WRITE_OPT, "write", false, "Actually persists the portfolio to the database"); options.addOption(writeOption); }