List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:com.aliyun.openservices.odps.console.commands.ShowPartitionsCommand.java
static Options initOptions() { Options opts = new Options(); Option project_name = new Option("p", true, "project name"); project_name.setRequired(false); opts.addOption(project_name);/*from w w w. j a v a 2s.co m*/ return opts; }
From source file:at.newmedialab.ldpath.template.LDTemplate.java
private static Options buildOptions() { Options result = new Options(); Option context = OptionBuilder.withArgName("uri").hasArg() .withDescription("URI of the context node to start from").create("context"); context.setRequired(true); result.addOption(context);/*from w w w . j av a 2 s . c o m*/ Option template = OptionBuilder.withArgName("file").hasArg() .withDescription("the template file to apply to the context resource").create("template"); template.setRequired(true); result.addOption(template); Option out = OptionBuilder.withArgName("file").hasArg() .withDescription("file where to write the output; if not given, will write to stdout") .create("out"); out.setRequired(false); result.addOption(out); Option loglevel = OptionBuilder.withArgName("level").hasArg() .withDescription("set the log level; default is 'warn'").create("loglevel"); result.addOption(loglevel); Option store = OptionBuilder.withArgName("dir").hasArg() .withDescription("cache the retrieved data in this directory").create("store"); result.addOption(store); return result; }
From source file:com.knewton.mapreduce.example.SSTableMRExample.java
private static Options buildOptions() { Options options = new Options(); Option option = new Option("s", "startDate", true, "The start date that student events should get included from. If not specified then it defaults to the beginning of time."); option.setRequired(false); options.addOption(option);//from w ww . j av a 2s . c om option = new Option("e", "endDate", true, "The end date that student events should get included. If not specified then it defaults to the \"end of time\"."); option.setRequired(false); options.addOption(option); option = new Option("c", "compress", false, "Set this option if you want the output to be compressed."); option.setRequired(false); options.addOption(option); options.addOption("h", "help", false, "Prints this help message."); return options; }
From source file:com.alibaba.rocketmq.example.benchmark.Producer.java
public static Options buildCommandlineOptions(final Options options) { Option opt = new Option("t", "threadCount", true, "Thread count, Default: 64"); opt.setRequired(false); options.addOption(opt);/*from w ww. j a v a 2 s. c om*/ opt = new Option("s", "messageSize", true, "Message Size, Default: 128"); opt.setRequired(false); options.addOption(opt); opt = new Option("k", "keyEnable", true, "Message Key Enable, Default: false"); opt.setRequired(false); options.addOption(opt); return options; }
From source file:com.damon.rocketmq.example.benchmark.Producer.java
public static Options buildCommandlineOptions(final Options options) { Option opt = new Option("w", "threadCount", true, "Thread count, Default: 64"); opt.setRequired(false); options.addOption(opt);/*www .ja v a 2 s . c o m*/ opt = new Option("s", "messageSize", true, "Message Size, Default: 128"); opt.setRequired(false); options.addOption(opt); opt = new Option("k", "keyEnable", true, "Message Key Enable, Default: false"); opt.setRequired(false); options.addOption(opt); opt = new Option("t", "topic", true, "Topic name, Default: BenchmarkTest"); opt.setRequired(false); options.addOption(opt); return options; }
From source file:com.ardoq.mavenImport.ArdoqMavenImport.java
private static Options initOptions() { Options options = new Options(); Option host = new Option("h", "host", true, "Ardoq host name"); options.addOption(host);//from w w w . ja v a 2 s . c o m Option token = new Option("t", "token", true, "Ardoq access token"); token.setRequired(true); options.addOption(token); Option workspace = new Option("w", "workspace", true, "Ardoq workspace name"); workspace.setRequired(true); options.addOption(workspace); Option model = new Option("m", "model", true, "Ardoq model name - defaults to Maven"); options.addOption(model); Option organization = new Option("o", "organization", true, "Ardoq organization name"); options.addOption(organization); Option extrarepo = new Option("r", "repository", true, "Extra repository URL"); options.addOption(extrarepo); Option extrarepouser = new Option("u", "username", true, "Extra repository user name"); options.addOption(extrarepouser); Option extrarepopass = new Option("p", "password", true, "Extra repository password"); options.addOption(extrarepopass); Option help = new Option("help", "print this help message"); options.addOption(help); return options; }
From source file:com.cloudera.beeswax.Server.java
/** * Parse command line options./*from w ww .j av a2 s . c om*/ * * -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.linkedin.helix.mock.storage.MockStorageProcess.java
@SuppressWarnings("static-access") private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();//from ww w .j av a 2 s . co m Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address") .create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required)"); Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create(); clusterOption.setArgs(1); clusterOption.setRequired(true); clusterOption.setArgName("Cluster name (Required)"); Option hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create(); hostOption.setArgs(1); hostOption.setRequired(true); hostOption.setArgName("Host name (Required)"); Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create(); portOption.setArgs(1); portOption.setRequired(true); portOption.setArgName("Host port (Required)"); Option relayClusterOption = OptionBuilder.withLongOpt(relayCluster) .withDescription("Provide relay cluster name").create(); relayClusterOption.setArgs(1); relayClusterOption.setRequired(true); relayClusterOption.setArgName("Relay cluster name (Required)"); Options options = new Options(); options.addOption(helpOption); options.addOption(zkServerOption); options.addOption(clusterOption); options.addOption(hostOption); options.addOption(portOption); options.addOption(relayClusterOption); return options; }
From source file:com.aliyun.openservices.odps.console.resource.ListResourcesCommand.java
static Options initOptions() { Options opts = new Options(); Option project_name = new Option("p", true, "project name"); Option showAllOption = new Option("l", false, "show source of resource"); project_name.setRequired(false); showAllOption.setRequired(false);//from w w w . j ava 2s.c o m opts.addOption(project_name); opts.addOption(showAllOption); return opts; }
From source file:at.newmedialab.ldpath.backend.linkeddata.LDQuery.java
private static Options buildOptions() { Options result = new Options(); OptionGroup query = new OptionGroup(); Option path = OptionBuilder.withArgName("path").hasArg() .withDescription("LD Path to evaluate on the file starting from the context").create("path"); Option program = OptionBuilder.withArgName("file").hasArg() .withDescription("LD Path program to evaluate on the file starting from the context") .create("program"); query.addOption(path);// w w w.ja v a 2s . c o m query.addOption(program); query.setRequired(true); result.addOptionGroup(query); Option context = OptionBuilder.withArgName("uri").hasArg() .withDescription("URI of the context node to start from").create("context"); context.setRequired(true); result.addOption(context); Option loglevel = OptionBuilder.withArgName("level").hasArg() .withDescription("set the log level; default is 'warn'").create("loglevel"); result.addOption(loglevel); Option store = OptionBuilder.withArgName("dir").hasArg() .withDescription("cache the retrieved data in this directory").create("store"); result.addOption(store); return result; }