List of usage examples for org.apache.commons.cli OptionBuilder hasOptionalArg
public static OptionBuilder hasOptionalArg()
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.CliOptionsBuilder.java
public CliOptionsBuilder hasOptionalArg() { OptionBuilder.hasOptionalArg(); return this; }
From source file:com.archivas.clienttools.arcmover.cli.ArcJobMgr.java
private void addOption(Options options, JobMgrAction action) { if (action.getArgName() != null) { options.addOption(OptionBuilder.hasOptionalArg().withArgName(action.getArgName()) .withDescription(action.getDescription()).withLongOpt(action.getCmdLineLongOpt()) .create(action.getCmdLineShortOpt())); } else {// ww w . ja v a 2 s. com options.addOption(OptionBuilder.withDescription(action.getDescription()) .withLongOpt(action.getCmdLineLongOpt()).create(action.getCmdLineShortOpt())); } }
From source file:com.archivas.clienttools.arcmover.cli.ArcProfileMgr.java
@SuppressWarnings({ "static-access" }) public Options getOptions() { if (cliOptions == null) { Options options = new Options(); OptionGroup operations = new OptionGroup(); // *** Adding a new option needs to be added to the cliOrder list operations.addOption(OptionBuilder.withDescription("Displays this help text (the default behavior).") .withLongOpt("help").create("h")); operations.addOption(OptionBuilder.hasOptionalArg().withArgName("profile_name").withDescription( "Lists information about the specified namespace profile. If <profile_name> is omitted, lists information about all namespace profiles.") .withLongOpt("list").create("l")); operations.addOption(OptionBuilder.hasArg().withArgName("profile_name") .withDescription("Deletes the specified namespace profile.").withLongOpt("delete").create("d")); operations.addOption(OptionBuilder.hasArg().withArgName("profile_name") .withDescription("Creates a namespace profile with the specified name.").withLongOpt("create") .create("c")); options.addOptionGroup(operations); // List the valid profile types dynamically String profileTypesToString = "Type of namespace for which you are creating the namespace profile: "; for (ProfileType type : ProfileType.values()) { if (type != ProfileType.FILESYSTEM) { // Filesystem is already createdcd profileTypesToString += (type.toString() + " | "); }/*from w w w .j a v a 2 s. c om*/ } profileTypesToString = profileTypesToString.substring(0, profileTypesToString.length() - 3); options.addOption(OptionBuilder.withArgName("profile_type").hasArg() .withDescription(profileTypesToString).withLongOpt("type").create()); options.addOption(OptionBuilder.withArgName("tenant_name").hasArg().withDescription( "Name of the tenant that owns the namespace for which you are creating the namespace profile.") .withLongOpt("tenant").create()); options.addOption(OptionBuilder.withArgName("namespace_name").hasArg() .withDescription("Name of the namespace for which you are creating the namespace profile.") .withLongOpt("namespace").create()); options.addOption(OptionBuilder.withArgName("username").hasArg() .withDescription("Username of the data access account to use for namespace access.") .withLongOpt("username").create()); options.addOption(OptionBuilder.withArgName("password").hasArg() .withDescription("Password of the data access account to use for namespace access.") .withLongOpt("password").create()); options.addOption(OptionBuilder.withArgName("hostname").hasArg() .withDescription("The fully qualified domain name of the HCP system.").withLongOpt("hostname") .create()); options.addOption( OptionBuilder.withDescription("Tells HCP-DM to use SSL when communicating with the HCP system.") .withLongOpt("ssl").create()); options.addOption(OptionBuilder.withDescription( "Tells HCP-DM to check whether custom metadata XML is well-formed prior to communicating with the HCP system.") .withLongOpt("check-cm").create()); options.addOption(OptionBuilder .withDescription("Log into namespace anonymously. Only valid with HCP 5.0 or later profile.") .withLongOpt("anon").create()); options.addOption(OptionBuilder.withDescription( "Does not test if the namespace configuration provided can access HCP while creating the profile.") .withLongOpt("notest").create()); options.addOption(OptionBuilder.withArgName("address1[,address2]...").hasArg().withDescription( "Comma-separated list of one or more IP addresses to use to connect to the HCP system. If omitted, HCP-DM uses the hostname.") .withLongOpt("ips").create()); if (ALLOW_PORT) { options.addOption(OptionBuilder.withArgName("port").hasArg() .withDescription("Port to connect to HCP on").withLongOpt("port").create()); } cliOptions = options; } return cliOptions; }
From source file:com.sikulix.core.SX.java
static void checkArgs(String[] args) { boolean hasUserArgs = false; for (String arg : args) { if ("--".equals(arg)) { hasUserArgs = true;/*from w w w . java 2 s .com*/ continue; } if (hasUserArgs) { trace("checkargs: user: %s", arg); userArgs.add(arg); } else { trace("checkargs: --sx: %s", arg); sxArgs.add(arg); } } if (sxArgs.size() > 0) { CommandLineParser parser = new PosixParser(); Options opts = new Options(); opts.addOption(OptionBuilder.hasOptionalArg().create('d')); opts.addOption(OptionBuilder.hasArg().create('o')); opts.addOption(OptionBuilder.hasArgs().create('r')); opts.addOption(OptionBuilder.hasArgs().create('t')); opts.addOption(OptionBuilder.hasArg(false).create('c')); opts.addOption(OptionBuilder.hasArg(false).create('q')); try { sxCommandArgs = parser.parse(opts, sxArgs.toArray(new String[0])); } catch (ParseException e) { terminate(1, "checkArgs: %s", e.getMessage()); } if (!isNull(sxCommandArgs)) { if (isArg("q")) { log.globalStop(); } else if (isArg("d")) { log.globalOn(log.DEBUG); } } } //TODO make options from SX args }
From source file:gov.llnl.lc.smt.command.event.SmtEvent.java
/** * Describe the method here/*from w w w . j av a2s. co m*/ * * @see gov.llnl.lc.smt.command.SmtCommand#init() * @see gov.llnl.lc.smt.command.SmtCommand#initCommonOptions() * * @return ***********************************************************/ @Override public boolean init() { USAGE = "[-h=<host url>] [-pn=<port num>] -sr"; HEADER = "smt-event - a tool for obtaining event information"; EXAMPLE = "examples:" + SmtConstants.NEW_LINE + "> smt-event -pn 10013" + SmtConstants.NEW_LINE + "> smt-event -pn 10013 -sr" + SmtConstants.NEW_LINE + "> smt-event -rH surface3h.his -dump 10" + SmtConstants.NEW_LINE + "> smt-event -q events" + SmtConstants.NEW_LINE + "> smt-event -rH surface3h.his -q status" + SmtConstants.NEW_LINE + "."; // terminate with nl // create and initialize the common options for this command initCommonOptions(); // add non-common options initMulitReadFileOptions(); // read the remainder of the file types SmtProperty sp = SmtProperty.SMT_QUERY_TYPE; Option qType = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=') .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName()); sp = SmtProperty.SMT_QUERY_LIST; Option qList = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription()); sp = SmtProperty.SMT_DUMP; Option dump = OptionBuilder.hasOptionalArg().withDescription(sp.getDescription()).withLongOpt(sp.getName()) .create(sp.getShortName()); sp = SmtProperty.SMT_STATUS; Option status = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName()) .create(sp.getShortName()); options.addOption(status); options.addOption(qType); options.addOption(qList); options.addOption(dump); return true; }
From source file:gov.llnl.lc.smt.command.system.SmtSystem.java
/** * Describe the method here/*from w ww.j a va 2s.co m*/ * * @see gov.llnl.lc.smt.command.SmtCommand#init() * @see gov.llnl.lc.smt.command.SmtCommand#initCommonOptions() * * @return ***********************************************************/ @Override public boolean init() { USAGE = "[-h=<host url>] [-pn=<port num>] [<sys guid>] -sr"; HEADER = "smt-system - a tool for obtaining high level system information"; EXAMPLE = "examples:" + SmtConstants.NEW_LINE + "> smt-system -pn 10011 - using the default port, list any & all systems" + SmtConstants.NEW_LINE + "> smt-system -ql - list the query options" + SmtConstants.NEW_LINE + "> smt-system -pn 10011 0006:6a00:e900:131d -q switches\n" + ". - list the switches associated with the system" + SmtConstants.NEW_LINE + "> smt-system 0006:6a00:e900:131e -q ports\n" + ". - show the port arrangement for the system" + SmtConstants.NEW_LINE + "> smt-system -pn 10013 -dump - show the systems (if any) in a verbose way" + SmtConstants.NEW_LINE + "."; // terminate with nl // create and initialize the common options for this command initCommonOptions(); SmtProperty sp = SmtProperty.SMT_QUERY_TYPE; Option qType = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=') .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName()); sp = SmtProperty.SMT_QUERY_LIST; Option qList = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription()); sp = SmtProperty.SMT_DUMP; Option dump = OptionBuilder.hasOptionalArg().withDescription(sp.getDescription()).withLongOpt(sp.getName()) .create(sp.getShortName()); sp = SmtProperty.SMT_STATUS; Option status = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName()) .create(sp.getShortName()); options.addOption(status); options.addOption(qType); options.addOption(qList); options.addOption(dump); return true; }
From source file:ml.shifu.shifu.ShifuCLI.java
@SuppressWarnings("static-access") private static Options buildModelSetOptions() { Options opts = new Options(); Option opt_cmt = OptionBuilder.hasArg().withDescription("The description for new model") .create(MODELSET_CMD_M);/* w w w . j a v a2s . co m*/ Option opt_new = OptionBuilder.hasArg().withDescription("To create an eval set").create(NEW); Option opt_type = OptionBuilder.hasArg().withDescription("Specify model type").create(MODELSET_CMD_TYPE); Option opt_run = OptionBuilder.hasOptionalArg().withDescription("To run eval set").create(EVAL_CMD_RUN); Option opt_dry = OptionBuilder.hasArg(false).withDescription("Dry run the train").create(TRAIN_CMD_DRY); Option opt_debug = OptionBuilder.hasArg(false).withDescription("Save the log of train process") .create(TRAIN_CMD_DEBUG); Option opt_model = OptionBuilder.hasArg(false).withDescription("Init model").create(INIT_CMD_MODEL); Option opt_concise = OptionBuilder.hasArg(false).withDescription("Export concise PMML") .create(EXPORT_CONCISE); // options for variable selection Option opt_reset = OptionBuilder.hasArg(false).withDescription("Reset all variables to finalSelect = false") .create(RESET); Option opt_filter_auto = OptionBuilder.hasArg(false) .withDescription("Auto filter variables by MissingRate, IV/KS, Correlation").create(FILTER_AUTO); Option opt_recover_auto = OptionBuilder.hasArg(false) .withDescription("Recover auto filtered variables from history.").create(RECOVER_AUTO); Option opt_recursive = OptionBuilder.hasArg().withDescription("Run variable selection recursively") .create(RECURSIVE); Option opt_correlation = OptionBuilder.hasArg(false) .withDescription("Compute correlation value for all column pairs.").create(CORRELATION); Option opt_correlation_short = OptionBuilder.hasArg(false) .withDescription("Compute correlation value for all column pairs.").create("c"); Option opt_psi = OptionBuilder.hasArg(false).withDescription("Compute psi value.").create(PSI); Option opt_psi_short = OptionBuilder.hasArg(false).withDescription("Compute psi value.").create(SHORT_PSI); Option opt_shuffle = OptionBuilder.hasArg(false).withDescription("Shuffle data after normalization") .create(SHUFFLE); Option opt_resume = OptionBuilder.hasArg(false).withDescription("Resume combo model training.") .create(RESUME); Option opt_list = OptionBuilder.hasArg(false).create(LIST); Option opt_delete = OptionBuilder.hasArg().create(DELETE); Option opt_score = OptionBuilder.hasOptionalArg().create(SCORE); Option opt_confmat = OptionBuilder.hasArg().create(CONFMAT); Option opt_perf = OptionBuilder.hasArg().create(PERF); Option opt_norm = OptionBuilder.hasArg().create(NORM); Option opt_eval = OptionBuilder.hasArg(false).create(EVAL_CMD); Option opt_init = OptionBuilder.hasArg(false).create(INIT_CMD); Option opt_nosort = OptionBuilder.hasArg(false).create(NOSORT); Option opt_ref = OptionBuilder.hasArg(true).create(REF); Option opt_filter = OptionBuilder.hasOptionalArg().create(FILTER); Option opt_strict = OptionBuilder.hasArg(false).create(STRICT); // options for variable re-binning Option opt_rebin = OptionBuilder.hasArg(false).create(REBIN); Option opt_vars = OptionBuilder.hasArg().create(VARS); Option opt_n = OptionBuilder.hasArg().create(N); Option opt_ivr = OptionBuilder.hasArg().create(IVR); Option opt_bic = OptionBuilder.hasArg().create(BIC); Option opt_save = OptionBuilder.hasArg(false).withDescription("save model").create(SAVE); Option opt_switch = OptionBuilder.hasArg(false).withDescription("switch model").create(SWITCH); Option opt_eval_model = OptionBuilder.hasArg().withDescription("").create(EVAL_MODEL); Option opt_tozipb = OptionBuilder.hasArg(false).create(TO_ZIPB); Option opt_totreeb = OptionBuilder.hasArg(false).create(TO_TREEB); Option opt_fi = OptionBuilder.hasArg(true).create(FI); opts.addOption(opt_cmt); opts.addOption(opt_new); opts.addOption(opt_type); opts.addOption(opt_run); opts.addOption(opt_perf); opts.addOption(opt_norm); opts.addOption(opt_dry); opts.addOption(opt_debug); opts.addOption(opt_model); opts.addOption(opt_concise); opts.addOption(opt_nosort); opts.addOption(opt_ref); opts.addOption(opt_filter); opts.addOption(opt_strict); opts.addOption(opt_reset); opts.addOption(opt_filter_auto); opts.addOption(opt_recover_auto); opts.addOption(opt_recursive); opts.addOption(opt_eval); opts.addOption(opt_init); opts.addOption(opt_shuffle); opts.addOption(opt_resume); opts.addOption(opt_list); opts.addOption(opt_delete); opts.addOption(opt_score); opts.addOption(opt_confmat); opts.addOption(opt_save); opts.addOption(opt_switch); opts.addOption(opt_eval_model); opts.addOption(opt_correlation); opts.addOption(opt_correlation_short); opts.addOption(opt_psi); opts.addOption(opt_psi_short); opts.addOption(opt_rebin); opts.addOption(opt_vars); opts.addOption(opt_n); opts.addOption(opt_ivr); opts.addOption(opt_bic); opts.addOption(opt_tozipb); opts.addOption(opt_totreeb); opts.addOption(opt_fi); return opts; }
From source file:nl.strohalm.cyclos.setup.Arguments.java
static Options buildOptions(final Locale locale) { final ResourceBundle bundle = Setup.getResourceBundle(locale); final Options options = new Options(); // help//from w w w . java 2 s .c o m OptionBuilder.withLongOpt("help"); OptionBuilder.hasArg(false); OptionBuilder.withDescription(bundle.getString("arg.help")); options.addOption(OptionBuilder.create('?')); // force OptionBuilder.withLongOpt("force"); OptionBuilder.hasArg(false); OptionBuilder.withDescription(bundle.getString("arg.force")); options.addOption(OptionBuilder.create('f')); // create database OptionBuilder.withLongOpt("database"); OptionBuilder.hasArg(false); OptionBuilder.withDescription(bundle.getString("arg.create-data-base")); options.addOption(OptionBuilder.create('d')); // export script OptionBuilder.withLongOpt("script"); OptionBuilder.hasOptionalArg(); OptionBuilder.withArgName("file"); OptionBuilder.withDescription(bundle.getString("arg.export-script")); options.addOption(OptionBuilder.create('s')); // create basic data OptionBuilder.withLongOpt("basic-data"); OptionBuilder.hasArg(false); OptionBuilder.withDescription(bundle.getString("arg.create-basic-data")); options.addOption(OptionBuilder.create('b')); // create initial data OptionBuilder.withLongOpt("initial-data"); OptionBuilder.hasArg(false); OptionBuilder.withDescription(bundle.getString("arg.create-initial-data")); options.addOption(OptionBuilder.create('i')); // create sms data OptionBuilder.withLongOpt("sms-data"); OptionBuilder.hasArg(false); OptionBuilder.withDescription(bundle.getString("arg.create-sms-data")); options.addOption(OptionBuilder.create('m')); return options; }
From source file:org.apache.nutch.api.NutchServer.java
private static Options createOptions() { Options options = new Options(); OptionBuilder.hasArg();//w w w.j a va2 s .c o m OptionBuilder.withArgName("logging level"); OptionBuilder.withDescription("Select a logging level for the NutchServer: \n" + "ALL|CONFIG|FINER|FINEST|INFO|OFF|SEVERE|WARNING"); options.addOption(OptionBuilder.create(CMD_LOG_LEVEL)); OptionBuilder.withDescription("Stop running NutchServer. " + "true value forces the Server to stop despite running jobs e.g. kills the tasks "); OptionBuilder.hasOptionalArg(); OptionBuilder.withArgName("force"); options.addOption(OptionBuilder.create(CMD_STOP)); OptionBuilder.withDescription("Show this help"); options.addOption(OptionBuilder.create(CMD_HELP)); OptionBuilder.withDescription("Port to use for restful API."); OptionBuilder.hasOptionalArg(); OptionBuilder.withArgName("port number"); options.addOption(OptionBuilder.create(CMD_PORT)); return options; }
From source file:org.apache.nutch.scoring.webgraph.NodeDumper.java
/** * Runs the node dumper tool.// w w w.j av a2 s . c om */ public int run(String[] args) throws Exception { Options options = new Options(); OptionBuilder.withArgName("help"); OptionBuilder.withDescription("show this help message"); Option helpOpts = OptionBuilder.create("help"); options.addOption(helpOpts); OptionBuilder.withArgName("webgraphdb"); OptionBuilder.hasArg(); OptionBuilder.withDescription("the web graph database to use"); Option webGraphDbOpts = OptionBuilder.create("webgraphdb"); options.addOption(webGraphDbOpts); OptionBuilder.withArgName("inlinks"); OptionBuilder.withDescription("show highest inlinks"); Option inlinkOpts = OptionBuilder.create("inlinks"); options.addOption(inlinkOpts); OptionBuilder.withArgName("outlinks"); OptionBuilder.withDescription("show highest outlinks"); Option outlinkOpts = OptionBuilder.create("outlinks"); options.addOption(outlinkOpts); OptionBuilder.withArgName("scores"); OptionBuilder.withDescription("show highest scores"); Option scoreOpts = OptionBuilder.create("scores"); options.addOption(scoreOpts); OptionBuilder.withArgName("topn"); OptionBuilder.hasOptionalArg(); OptionBuilder.withDescription("show topN scores"); Option topNOpts = OptionBuilder.create("topn"); options.addOption(topNOpts); OptionBuilder.withArgName("output"); OptionBuilder.hasArg(); OptionBuilder.withDescription("the output directory to use"); Option outputOpts = OptionBuilder.create("output"); options.addOption(outputOpts); OptionBuilder.withArgName("asEff"); OptionBuilder.withDescription("Solr ExternalFileField compatible output format"); Option effOpts = OptionBuilder.create("asEff"); options.addOption(effOpts); OptionBuilder.hasArgs(2); OptionBuilder.withDescription("group <host|domain> <sum|max>"); Option groupOpts = OptionBuilder.create("group"); options.addOption(groupOpts); OptionBuilder.withArgName("asSequenceFile"); OptionBuilder.withDescription("whether to output as a sequencefile"); Option sequenceFileOpts = OptionBuilder.create("asSequenceFile"); options.addOption(sequenceFileOpts); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption("help") || !line.hasOption("webgraphdb")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("NodeDumper", options); return -1; } String webGraphDb = line.getOptionValue("webgraphdb"); boolean inlinks = line.hasOption("inlinks"); boolean outlinks = line.hasOption("outlinks"); long topN = (line.hasOption("topn") ? Long.parseLong(line.getOptionValue("topn")) : Long.MAX_VALUE); // get the correct dump type String output = line.getOptionValue("output"); DumpType type = (inlinks ? DumpType.INLINKS : outlinks ? DumpType.OUTLINKS : DumpType.SCORES); NameType nameType = null; AggrType aggrType = null; String[] group = line.getOptionValues("group"); if (group != null && group.length == 2) { nameType = (group[0].equals("host") ? NameType.HOST : group[0].equals("domain") ? NameType.DOMAIN : null); aggrType = (group[1].equals("sum") ? AggrType.SUM : group[1].equals("sum") ? AggrType.MAX : null); } // Use ExternalFileField? boolean asEff = line.hasOption("asEff"); boolean asSequenceFile = line.hasOption("asSequenceFile"); dumpNodes(new Path(webGraphDb), type, topN, new Path(output), asEff, nameType, aggrType, asSequenceFile); return 0; } catch (Exception e) { LOG.error("NodeDumper: " + StringUtils.stringifyException(e)); return -2; } }