List of usage examples for org.apache.commons.cli Option UNLIMITED_VALUES
int UNLIMITED_VALUES
To view the source code for org.apache.commons.cli Option UNLIMITED_VALUES.
Click Source Link
From source file:eu.stratosphere.pact.client.CliFrontend.java
/** * Builds command line options for the info action. * //from w w w .j av a2s . com * @return Command line options for the info action. */ private Options getInfoOptions() { Options options = new Options(); // info options DESCR_OPTION.setRequired(false); options.addOption(DESCR_OPTION); PLAN_OPTION.setRequired(false); options.addOption(PLAN_OPTION); JAR_OPTION.setRequired(false); JAR_OPTION.setArgName("jarfile"); options.addOption(JAR_OPTION); CLASS_OPTION.setRequired(false); CLASS_OPTION.setArgName("classname"); options.addOption(CLASS_OPTION); ARGS_OPTION.setRequired(false); ARGS_OPTION.setArgName("programArgs"); ARGS_OPTION.setArgs(Option.UNLIMITED_VALUES); options.addOption(ARGS_OPTION); return options; }
From source file:com.rabbitmq.examples.MulticastMain.java
private static Options getOptions() { Options options = new Options(); options.addOption(new Option("?", "help", false, "show usage")); options.addOption(new Option("h", "uri", true, "AMQP URI")); options.addOption(new Option("t", "type", true, "exchange type")); options.addOption(new Option("e", "exchange", true, "exchange name")); options.addOption(new Option("u", "queue", true, "queue name")); options.addOption(new Option("i", "interval", true, "sampling interval")); options.addOption(new Option("r", "rate", true, "rate limit")); options.addOption(new Option("x", "producers", true, "producer count")); options.addOption(new Option("y", "consumers", true, "consumer count")); options.addOption(new Option("m", "ptxsize", true, "producer tx size")); options.addOption(new Option("n", "ctxsize", true, "consumer tx size")); options.addOption(new Option("c", "confirm", true, "max unconfirmed publishes")); options.addOption(new Option("a", "autoack", false, "auto ack")); options.addOption(new Option("q", "qos", true, "qos prefetch count")); options.addOption(new Option("s", "size", true, "message size")); options.addOption(new Option("z", "time", true, "time limit")); Option flag = new Option("f", "flag", true, "message flag"); flag.setArgs(Option.UNLIMITED_VALUES); options.addOption(flag);// w w w . j ava 2 s . c om options.addOption(new Option("M", "framemax", true, "frame max")); options.addOption(new Option("b", "heartbeat", true, "heartbeat interval")); return options; }
From source file:com.example.dlp.Inspect.java
/** * Command line application to inspect data using the Data Loss Prevention API. * Supported data formats: string, file, text file on GCS, BigQuery table, and Datastore entity */// w w w. ja v a 2 s. c om public static void main(String[] args) throws Exception { OptionGroup optionsGroup = new OptionGroup(); optionsGroup.setRequired(true); Option stringOption = new Option("s", "string", true, "inspect string"); optionsGroup.addOption(stringOption); Option fileOption = new Option("f", "file path", true, "inspect input file path"); optionsGroup.addOption(fileOption); Option gcsOption = new Option("gcs", "Google Cloud Storage", false, "inspect GCS file"); optionsGroup.addOption(gcsOption); Option datastoreOption = new Option("ds", "Google Datastore", false, "inspect Datastore kind"); optionsGroup.addOption(datastoreOption); Option bigqueryOption = new Option("bq", "Google BigQuery", false, "inspect BigQuery table"); optionsGroup.addOption(bigqueryOption); Options commandLineOptions = new Options(); commandLineOptions.addOptionGroup(optionsGroup); Option minLikelihoodOption = Option.builder("minLikelihood").hasArg(true).required(false).build(); commandLineOptions.addOption(minLikelihoodOption); Option maxFindingsOption = Option.builder("maxFindings").hasArg(true).required(false).build(); commandLineOptions.addOption(maxFindingsOption); Option infoTypesOption = Option.builder("infoTypes").hasArg(true).required(false).build(); infoTypesOption.setArgs(Option.UNLIMITED_VALUES); commandLineOptions.addOption(infoTypesOption); Option includeQuoteOption = Option.builder("includeQuote").hasArg(true).required(false).build(); commandLineOptions.addOption(includeQuoteOption); Option bucketNameOption = Option.builder("bucketName").hasArg(true).required(false).build(); commandLineOptions.addOption(bucketNameOption); Option gcsFileNameOption = Option.builder("fileName").hasArg(true).required(false).build(); commandLineOptions.addOption(gcsFileNameOption); Option datasetIdOption = Option.builder("datasetId").hasArg(true).required(false).build(); commandLineOptions.addOption(datasetIdOption); Option tableIdOption = Option.builder("tableId").hasArg(true).required(false).build(); commandLineOptions.addOption(tableIdOption); Option projectIdOption = Option.builder("projectId").hasArg(true).required(false).build(); commandLineOptions.addOption(projectIdOption); Option datastoreNamespaceOption = Option.builder("namespace").hasArg(true).required(false).build(); commandLineOptions.addOption(datastoreNamespaceOption); Option datastoreKindOption = Option.builder("kind").hasArg(true).required(false).build(); commandLineOptions.addOption(datastoreKindOption); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd; try { cmd = parser.parse(commandLineOptions, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp(Inspect.class.getName(), commandLineOptions); System.exit(1); return; } Likelihood minLikelihood = Likelihood.valueOf( cmd.getOptionValue(minLikelihoodOption.getOpt(), Likelihood.LIKELIHOOD_UNSPECIFIED.name())); int maxFindings = Integer.parseInt(cmd.getOptionValue(maxFindingsOption.getOpt(), "0")); boolean includeQuote = Boolean.parseBoolean(cmd.getOptionValue(includeQuoteOption.getOpt(), "true")); List<InfoType> infoTypesList = Collections.emptyList(); if (cmd.hasOption(infoTypesOption.getOpt())) { infoTypesList = new ArrayList<>(); String[] infoTypes = cmd.getOptionValues(infoTypesOption.getOpt()); for (String infoType : infoTypes) { infoTypesList.add(InfoType.newBuilder().setName(infoType).build()); } } // string inspection if (cmd.hasOption("s")) { String val = cmd.getOptionValue(stringOption.getOpt()); inspectString(val, minLikelihood, maxFindings, infoTypesList, includeQuote); } else if (cmd.hasOption("f")) { String filePath = cmd.getOptionValue(fileOption.getOpt()); inspectFile(filePath, minLikelihood, maxFindings, infoTypesList, includeQuote); // gcs file inspection } else if (cmd.hasOption("gcs")) { String bucketName = cmd.getOptionValue(bucketNameOption.getOpt()); String fileName = cmd.getOptionValue(gcsFileNameOption.getOpt()); inspectGcsFile(bucketName, fileName, minLikelihood, infoTypesList); // datastore kind inspection } else if (cmd.hasOption("ds")) { String namespaceId = cmd.getOptionValue(datastoreNamespaceOption.getOpt(), ""); String kind = cmd.getOptionValue(datastoreKindOption.getOpt()); // use default project id when project id is not specified String projectId = cmd.getOptionValue(projectIdOption.getOpt(), ServiceOptions.getDefaultProjectId()); inspectDatastore(projectId, namespaceId, kind, minLikelihood, infoTypesList); } else if (cmd.hasOption("bq")) { String datasetId = cmd.getOptionValue(datasetIdOption.getOpt()); String tableId = cmd.getOptionValue(tableIdOption.getOpt()); // use default project id when project id is not specified String projectId = cmd.getOptionValue(projectIdOption.getOpt(), ServiceOptions.getDefaultProjectId()); inspectBigquery(projectId, datasetId, tableId, minLikelihood, infoTypesList); } }
From source file:com.netcrest.pado.tools.pado.PadoShell.java
private void parseArgs(String args[]) { Options options = new Options(); Option opt = OptionBuilder.create("dir"); opt.setArgs(1);/*from ww w . java 2s.c o m*/ opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("i"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("e"); opt.setArgs(Option.UNLIMITED_VALUES); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("f"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("jar"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("l"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("a"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("u"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); opt = OptionBuilder.create("p"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); // domain opt = OptionBuilder.create("d"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); // history opt = OptionBuilder.create("h"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); // editor (vi or emacs) - default vi opt = OptionBuilder.create("o"); opt.setArgs(1); opt.setOptionalArg(true); options.addOption(opt); options.addOption("n", false, ""); options.addOption("v", false, ""); options.addOption("?", false, ""); CommandLine commandLine = null; try { commandLine = cliParseCommandLine(options, args); } catch (Exception e) { Logger.error(e); } if (commandLine == null || commandLine.hasOption('?')) { usage(); exit(0); } if (commandLine.hasOption('v')) { PadoVersion padoVersion = new PadoVersion(); println("v" + padoVersion.getVersion()); exit(0); } if (commandLine.hasOption("dir") && commandLine.getOptionValue("dir") != null) { // jarDirectoryPath = commandLine.getOptionValue("dir"); // ignore dir. dir is handled by the shell script. } if (commandLine.hasOption("i") && commandLine.getOptionValue("i") != null) { inputFilePath = commandLine.getOptionValue("i"); } if (commandLine.hasOption("e") && commandLine.getOptionValue("e") != null) { inputCommands = commandLine.getOptionValues("e"); } if (commandLine.hasOption("f") && commandLine.getOptionValue("f") != null) { scriptFilePath = commandLine.getOptionValue("f"); } if (commandLine.hasOption("jar") && commandLine.getOptionValue("jar") != null) { jarPaths = commandLine.getOptionValue("jar"); } if (commandLine.hasOption("h") && commandLine.getOptionValue("h") != null) { historyFileName = commandLine.getOptionValue("h"); } if (commandLine.hasOption("o") && commandLine.getOptionValue("o") != null) { editorName = commandLine.getOptionValue("o"); // Only vi and emacs supported. Default to vi if a bad name. if (editorName.equalsIgnoreCase("vi") == false && editorName.equalsIgnoreCase("emacs")) { editorName = "vi"; } } locators = commandLine.getOptionValue("l"); appId = commandLine.getOptionValue("a"); user = commandLine.getOptionValue("u"); String pw = commandLine.getOptionValue("p"); if (pw != null) { password = pw.toCharArray(); } ignorePadoRcFile = commandLine.hasOption("n"); if (commandLine.hasOption("h")) { setHistoryPerSession(Boolean.TRUE); } interactiveMode = scriptFilePath == null && inputCommands == null; if (interactiveMode) { println(); println(PadoShellLogo.getPadoLogo()); println(PadoShellLogo.getCopyrights()); println(); } envProperties.putAll(System.getenv()); }
From source file:de.uni_koblenz.ist.utilities.option_handler.OptionHandler.java
private void appendAdditionalArguments(StringBuilder out) { if (argumentCount != 0) { out.append(" ("); if (optionalArgument) { out.append("["); }/*from w w w .j av a 2s . com*/ if (argumentCount == Option.UNLIMITED_VALUES) { appendArgument(out); out.append(" "); out.append("{"); appendArgument(out); out.append("}"); } else { for (int i = 0; i < argumentCount; i++) { appendArgument(out); } } if (optionalArgument) { out.append("]"); } out.append(")"); } }
From source file:com.scistor.dshell.ScistorClient.java
ScistorClient(String appMasterMainClass, Configuration conf) { this.conf = conf; this.appMasterMainClass = appMasterMainClass; yarnClient = YarnClient.createYarnClient(); yarnClient.init(conf);/* ww w. j av a2s . c o m*/ opts = new Options(); opts.addOption("appname", true, "Application Name. Default value - DistributedShell"); opts.addOption("priority", true, "Application Priority. Default 0"); opts.addOption("queue", true, "RM Queue in which this application is to be submitted"); opts.addOption("timeout", true, "Application timeout in milliseconds"); opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run the application master"); opts.addOption("master_vcores", true, "Amount of virtual cores to be requested to run the application master"); opts.addOption("jar", true, "Jar file containing the application master"); // opts.addOption("container_jars", true, "The jars that containers will run .Separated by comma"); // opts.addOption("shell_command", true, "Shell command to be executed by " + "the Application Master. Can only specify either --shell_command " + "or --shell_script"); opts.addOption("shell_script", true, "Location of the shell script to be " + "executed. Can only specify either --shell_command or --shell_script"); opts.addOption("shell_args", true, "Command line args for the shell script." + "Multiple args can be separated by empty space."); opts.getOption("shell_args").setArgs(Option.UNLIMITED_VALUES); opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val pairs"); opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers"); opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run the shell command"); opts.addOption("container_vcores", true, "Amount of virtual cores to be requested to run the shell command"); opts.addOption("num_containers", true, "No. of containers on which the shell command needs to be executed"); opts.addOption("log_properties", true, "log4j.properties file"); opts.addOption("keep_containers_across_application_attempts", false, "Flag to indicate whether to keep containers across application attempts." + " If the flag is true, running containers will not be killed when" + " application attempt fails and these containers will be retrieved by" + " the new application attempt "); opts.addOption("debug", false, "Dump out debug information"); opts.addOption("help", false, "Print usage"); }
From source file:hadoop.yarn.distributedshell.DshellClient.java
DshellClient(String appMasterMainClass, Configuration conf) { this.conf = conf; this.appMasterMainClass = appMasterMainClass; yarnClient = YarnClient.createYarnClient(); yarnClient.init(conf);//from ww w .j a v a 2s. com opts = new Options(); opts.addOption("appname", true, "Application Name. Default value - DistributedShell"); opts.addOption("priority", true, "Application Priority. Default 0"); opts.addOption("queue", true, "RM Queue in which this application is to be submitted"); opts.addOption("timeout", true, "Application timeout in milliseconds"); opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run the application master"); opts.addOption("master_vcores", true, "Amount of virtual cores to be requested to run the application master"); opts.addOption("jar", true, "Jar file containing the application master"); // opts.addOption("container_files", true, "The files that containers will run . Separated by comma"); opts.addOption("container_archives", true, "The archives that containers will unzip. Separated by comma"); // opts.addOption("shell_command", true, "Shell command to be executed by " + "the Application Master. Can only specify either --shell_command " + "or --shell_script"); opts.addOption("shell_script", true, "Location of the shell script to be " + "executed. Can only specify either --shell_command or --shell_script"); opts.addOption("shell_args", true, "Command line args for the shell script." + "Multiple args can be separated by empty space."); opts.getOption("shell_args").setArgs(Option.UNLIMITED_VALUES); opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val pairs"); opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers"); opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run the shell command"); opts.addOption("container_vcores", true, "Amount of virtual cores to be requested to run the shell command"); // opts.addOption("num_containers", true, // "No. of containers on which the shell command needs to be executed");//container?1 opts.addOption("log_properties", true, "log4j.properties file"); opts.addOption("keep_containers_across_application_attempts", false, "Flag to indicate whether to keep containers across application attempts." + " If the flag is true, running containers will not be killed when" + " application attempt fails and these containers will be retrieved by" + " the new application attempt "); opts.addOption("debug", false, "Dump out debug information"); opts.addOption("help", false, "Print usage"); }
From source file:com.bigjob.Client.java
Client(Configuration conf) { this.conf = conf; //this.appMasterMainClass = appMasterMainClass; opts = new Options(); opts.addOption("appname", true, "Application Name. Default value - DistributedShell"); opts.addOption("priority", true, "Application Priority. Default 0"); opts.addOption("queue", true, "RM Queue in which this application is to be submitted"); opts.addOption("config", true, "HADOOP_CONF_DIR"); opts.addOption("timeout", true, "Application timeout in milliseconds"); opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run the application master"); opts.addOption("master_vcores", true, "Amount of virtual cores to be requested to run the application master"); opts.addOption("jar", true, "Jar file containing the application master"); opts.addOption("shell_command", true, "Shell command to be executed by " + "the Application Master. Can only specify either --shell_command " + "or --shell_script"); opts.addOption("shell_script", true, "Location of the shell script to be " + "executed. Can only specify either --shell_command or --shell_script"); opts.addOption("shell_args", true, "Command line args for the shell script." + "Multiple args can be separated by empty space."); opts.getOption("shell_args").setArgs(Option.UNLIMITED_VALUES); opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val pairs"); opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers"); opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run the shell command"); opts.addOption("container_vcores", true, "Amount of virtual cores to be requested to run the shell command"); opts.addOption("num_containers", true, "No. of containers on which the shell command needs to be executed"); opts.addOption("service_url", true, "URL of YARN/HDFS service, e.g. yarn://localhost?fs=hdfs://localhost"); opts.addOption("log_properties", true, "log4j.properties file"); opts.addOption("debug", false, "Dump out debug information"); opts.addOption("help", false, "Print usage"); }
From source file:com.sogou.dockeronyarn.client.DockerClient.java
DockerClient(String appMasterMainClass, Configuration conf) { this.conf = conf; this.appMasterMainClass = appMasterMainClass; yarnClient = YarnClient.createYarnClient(); yarnClient.init(conf);//from w ww .ja va 2s .c o m opts = new Options(); opts.addOption("appname", true, "Application Name. Default value - DistributedShell"); opts.addOption("priority", true, "Application Priority. Default 0"); opts.addOption("queue", true, "RM Queue in which this application is to be submitted"); opts.addOption("timeout", true, "Application timeout in milliseconds"); opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run the application master"); opts.addOption("master_vcores", true, "Amount of virtual cores to be requested to run the application master"); opts.addOption("jar", true, "Jar file containing the application master"); opts.addOption("shell_command", true, "Shell command to be executed by " + "the Application Master. Can only specify either --shell_command " + "or --shell_script"); opts.addOption("shell_script", true, "Location of the shell script to be " + "executed. Can only specify either --shell_command or --shell_script"); opts.addOption("shell_args", true, "Command line args for the shell script." + "Multiple args can be separated by empty space."); opts.getOption("shell_args").setArgs(Option.UNLIMITED_VALUES); opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val pairs"); opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers"); opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run the shell command"); opts.addOption("container_vcores", true, "Amount of virtual cores to be requested to run the shell command"); opts.addOption("num_containers", true, "No. of containers on which the shell command needs to be executed"); opts.addOption("log_properties", true, "log4j.properties file"); opts.addOption("container_retry", true, "container retry count"); opts.addOption("keep_containers_across_application_attempts", false, "Flag to indicate whether to keep containers across application attempts." + " If the flag is true, running containers will not be killed when" + " application attempt fails and these containers will be retrieved by" + " the new application attempt "); opts.addOption("debug", false, "Dump out debug information"); opts.addOption("help", false, "Print usage"); }
From source file:com.epam.hadoop.nv.yarn.Client.java
Client(String appMasterMainClass, Configuration conf) { this.conf = conf; this.appMasterMainClass = appMasterMainClass; yarnClient = YarnClient.createYarnClient(); yarnClient.init(conf);/*from w ww . j a v a 2 s . c o m*/ opts = new Options(); opts.addOption("appname", true, "Application Name. Default value - DistributedShell"); opts.addOption("priority", true, "Application Priority. Default 0"); opts.addOption("queue", true, "RM Queue in which this application is to be submitted"); opts.addOption("timeout", true, "Application timeout in milliseconds"); opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run the application master"); opts.addOption("master_vcores", true, "Amount of virtual cores to be requested to run the application master"); opts.addOption("jar", true, "Jar file containing the application master"); opts.addOption("shell_command", true, "Shell command to be executed by " + "the Application Master. Can only specify either --shell_command " + "or --shell_script"); opts.addOption("shell_script", true, "Location of the shell script to be " + "executed. Can only specify either --shell_command or --shell_script"); opts.addOption("shell_args", true, "Command line args for the shell script." + "Multiple args can be separated by empty space."); opts.getOption("shell_args").setArgs(Option.UNLIMITED_VALUES); opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val pairs"); opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers"); opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run the shell command"); opts.addOption("container_vcores", true, "Amount of virtual cores to be requested to run the shell command"); opts.addOption("num_containers", true, "No. of containers on which the shell command needs to be executed"); opts.addOption("log_properties", true, "log4j.properties file"); opts.addOption("keep_containers_across_application_attempts", false, "Flag to indicate whether to keep containers across application attempts." + " If the flag is true, running containers will not be killed when" + " application attempt fails and these containers will be retrieved by" + " the new application attempt "); opts.addOption("debug", false, "Dump out debug information"); opts.addOption("help", false, "Print usage"); }