List of usage examples for org.apache.commons.cli OptionBuilder hasArgs
public static OptionBuilder hasArgs()
From source file:edu.harvard.med.iccbl.screensaver.io.libraries.CreateLibraryWells.java
@SuppressWarnings("static-access") public static void main(String[] args) { final CommandLineApplication app = new CommandLineApplication(args); app.addCommandLineOption(OptionBuilder.hasArgs().isRequired().withArgName("short name") .withLongOpt("short-name").withDescription("a short name for identifying the library").create("l")); app.processOptions(true, false);// w ww .j a va 2 s . c o m final GenericEntityDAO dao = (GenericEntityDAO) app.getSpringBean("genericEntityDao"); dao.doInTransaction(new DAOTransaction() { @Override public void runTransaction() { try { LibraryCreator libraryCreator = (LibraryCreator) app.getSpringBean("libraryCreator"); List<String> libraryShortNames = app.getCommandLineOptionValues("l"); for (String libraryShortName : libraryShortNames) { libraryCreator.createWells( dao.findEntityByProperty(Library.class, "shortName", libraryShortName)); } } catch (Exception e) { e.printStackTrace(); log.error(e.toString()); System.err.println("error: " + e.getMessage()); System.exit(1); } } }); }
From source file:jp.primecloud.auto.tool.management.main.Main.java
public static void main(String args[]) { Options options = new Options(); options.addOption("Z", false, "Zabbix mode"); options.addOption("U", false, "UPDATE mode"); options.addOption("S", false, "SELECT mode"); options.addOption("C", false, "Create Mode"); options.addOption("P", false, "Show Platform"); options.addOption("L", false, "Show Users"); options.addOption("E", false, "Ecrypt UserPassword"); options.addOption("I", false, "IaasGateway Mode"); options.addOption("A", false, "PCC-API Genarate ID or Key Mode"); options.addOption("W", false, "Decrypt UserPassword"); options.addOption("username", true, "Create the username"); options.addOption("password", true, "Create the password"); options.addOption("firstname", true, "Create the firstname"); options.addOption("familyname", true, "Create the familyname"); options.addOption("userno", true, "Create the userno"); options.addOption("dburl", "connectionurl", true, "PrimeCloud Controller database url"); options.addOption("dbuser", "username", true, "PrimeCloud Controller database username"); options.addOption("dbpass", "password", true, "PrimeCloud Controller database password"); options.addOption("sql", true, "SQL"); options.addOption("columnname", true, "columnName"); options.addOption("columntype", true, "columnType"); options.addOption("salt", true, "Salt"); OptionBuilder.withLongOpt("prepared"); OptionBuilder.hasArgs(); OptionBuilder.withDescription("execute as PreparedStatement"); OptionBuilder.withArgName("params"); Option optionPrepared = OptionBuilder.create(); options.addOption(optionPrepared);// w w w . jav a2 s . co m // for Zabbix options.addOption("enable", false, "enable"); options.addOption("disable", false, "disable"); options.addOption("get", false, "getUser from zabbix"); options.addOption("check", false, "API setting check for zabbix"); options.addOption("config", true, "Property can obtain from management-config.properties"); options.addOption("platformkind", true, "Platform kind. e.g. ec2 and ec2_vpc or vmware"); options.addOption("platformname", true, "Platform can obtain from auto-config.xml"); options.addOption("platformno", true, "Platform can obtain from auto-config.xml"); // for IaasGateway(AWS, Cloudstack) options.addOption("keyname", true, "import your key pair as keyName"); options.addOption("publickey", true, "import your public key"); // for PCC options.addOption("accessid", true, "accessid for PCC-API"); options.addOption("secretkey", true, "secretkey for PCC-API"); options.addOption("generatetype", true, "genarateType for PCC-API"); options.addOption("h", "help", false, "help"); CommandLineParser parser = new BasicParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); } catch (ParseException e) { System.out.println( "???????? -h?????????"); return; } if (commandLine.hasOption("h")) { HelpFormatter f = new HelpFormatter(); f.printHelp("PCC script ", options); } ManagementConfigLoader.init(); //? //Zabbix? if (commandLine.hasOption("Z")) { if (commandLine.hasOption("C")) { //Zabbix? ZabbixMain.createExecute(commandLine); } else if (commandLine.hasOption("U")) { //Zabbix ZabbixMain.updateExecute(commandLine); } else if (commandLine.hasOption("disable")) { //Zabbix ZabbixMain.disableExecute(commandLine); } else if (commandLine.hasOption("enable")) { //Zabbix ZabbixMain.enableExecute(commandLine); } else if (commandLine.hasOption("get")) { //Zabbix? ZabbixMain.getUser(commandLine); } else if (commandLine.hasOption("check")) { //Zabbix?? ZabbixMain.checkApiVersion(); } //PCC? } else if (commandLine.hasOption("U")) { if (commandLine.hasOption("prepared")) { SQLMain.updateExecutePrepared(commandLine); } else { //Update? SQLMain.updateExecute(commandLine); } } else if (commandLine.hasOption("S")) { //Select? SQLMain.selectExecute(commandLine); } else if (commandLine.hasOption("P")) { //? ConfigMain.showPlatforms(); } else if (commandLine.hasOption("L")) { //PCC? UserService.showUserPlatform(); } else if (commandLine.hasOption("config")) { //??? ConfigMain.getProperty(commandLine.getOptionValue("config")); } else if (commandLine.hasOption("platformname") && commandLine.hasOption("platformkind")) { //?????? ConfigMain.getPlatformNo(commandLine.getOptionValue("platformname"), commandLine.getOptionValue("platformkind")); } else if (commandLine.hasOption("E")) { //PCC?? UserService.encryptUserPassword(commandLine.getOptionValue("password")); } else if (commandLine.hasOption("I")) { //IaasGatewayCall??AWS or Cloudstack??? IaasGatewayMain.importExecute(commandLine); } else if (commandLine.hasOption("A")) { PccApiGenerateService.genarate(commandLine); } else if (commandLine.hasOption("W")) { //PCC?? UserService.decryptUserPassword(commandLine.getOptionValue("password"), commandLine.getOptionValue("salt")); } }
From source file:TmlCommandLine.java
@SuppressWarnings("static-access") public static void main(String[] args) { long time = System.nanoTime(); options = new Options(); // Repository options.addOption(OptionBuilder.withDescription( "Full path of the repository folder, where TML will retrieve (or insert) documents. (e.g. /home/user/lucene).") .hasArg().withArgName("folder").isRequired().create("repo")); // Verbosity//from w w w .j a va2 s. c om options.addOption( OptionBuilder.withDescription("Verbose output in the console (it goes verbose to the log file).") .hasArg(false).isRequired(false).create("v")); // Operation on corpus options.addOption(OptionBuilder.hasArg(false).withDescription("Performs an operation on a corpus.") .isRequired(false).create("O")); // The list of operations options.addOption(OptionBuilder.withDescription( "The list of operations you want to execute on the corpus. (e.g. PassageDistances,PassageSimilarity .") .hasArgs().withValueSeparator(',').withArgName("list").isRequired(false).withLongOpt("operations") .create()); // The file to store the results options.addOption(OptionBuilder.withDescription("Folder where to store the results. (e.g. results/run01/).") .hasArg().withArgName("folder").isRequired(false).withLongOpt("oresults").create()); // The corpus on which operate options.addOption(OptionBuilder.withDescription( "Lucene query that defines the corpus to operate with. (e.g. \"type:sentence AND reference:Document01\").") .hasArg().withArgName("query").isRequired(false).withLongOpt("ocorpus").create()); // The corpus on which operate options.addOption(OptionBuilder.withDescription( "Use all documents in repository as single document corpora, it can be sentence or paragraph based. (e.g. sentence).") .hasArgs().withArgName("type").isRequired(false).withLongOpt("oalldocs").create()); // The properties file for the corpus options.addOption(OptionBuilder.withDescription("Properties file with the corpus parameters (optional).") .hasArg().withArgName("parameter file").isRequired(false).withLongOpt("ocpar").create()); // Background knowledge corpus options.addOption(OptionBuilder.withDescription( "Lucene query that defines a background knowledge on which the corpus will be projected. (e.g. \"type:sentences AND reference:Document*\").") .hasArg().withArgName("query").isRequired(false).withLongOpt("obk").create()); // Background knowledge parameters options.addOption(OptionBuilder.withDescription( "Properties file with the background knowledge corpus parameters, if not set it will use the same as the corpus.") .hasArg().withArgName("parameter file").isRequired(false).withLongOpt("obkpar").create()); // Term selection String criteria = ""; for (TermSelection tsel : TermSelection.values()) { criteria += "," + tsel.name(); } criteria = criteria.substring(1); options.addOption(OptionBuilder.hasArgs().withArgName("name") .withDescription("Name of the Term selection criteria (" + criteria + ").").isRequired(false) .withValueSeparator(',').withLongOpt("otsel").create()); // Term selection threshold options.addOption(OptionBuilder.hasArgs().withArgName("number") .withDescription("Threshold for the tsel criteria option.").withType(Integer.TYPE).isRequired(false) .withValueSeparator(',').withLongOpt("otselth").create()); // Dimensionality reduction criteria = ""; for (DimensionalityReduction dim : DimensionalityReduction.values()) { criteria += "," + dim.name(); } criteria = criteria.substring(1); options.addOption(OptionBuilder.hasArgs().withArgName("list") .withDescription("Name of the Dimensionality Reduction criteria. (e.g. " + criteria + ").") .isRequired(false).withValueSeparator(',').withLongOpt("odim").create()); // Dimensionality reduction threshold options.addOption(OptionBuilder.hasArgs().withArgName("list") .withDescription("Threshold for the dim options. (e.g. 0,1,2).").isRequired(false) .withValueSeparator(',').withLongOpt("odimth").create()); // Local weight criteria = ""; for (LocalWeight weight : LocalWeight.values()) { criteria += "," + weight.name(); } criteria = criteria.substring(1); options.addOption(OptionBuilder.hasArgs().withArgName("list") .withDescription("Name of the Local Weight to apply. (e.g." + criteria + ").").isRequired(false) .withValueSeparator(',').withLongOpt("otwl").create()); // Global weight criteria = ""; for (GlobalWeight weight : GlobalWeight.values()) { criteria += "," + weight.name(); } criteria = criteria.substring(1); options.addOption(OptionBuilder.hasArgs().withArgName("list") .withDescription("Name of the Global Weight to apply. (e.g. " + criteria + ").").isRequired(false) .withValueSeparator(',').withLongOpt("otwg").create()); // Use Lanczos options.addOption(OptionBuilder.hasArg(false).withDescription("Use Lanczos for SVD decomposition.") .isRequired(false).withLongOpt("olanczos").create()); // Inserting documents in repository options.addOption(OptionBuilder.hasArg(false).withDescription("Insert documents into repository.") .isRequired(false).create("I")); // Max documents to insert options.addOption(OptionBuilder.hasArg().withArgName("number") .withDescription("Maximum number of documents to index or use in an operation.") .withType(Integer.TYPE).isRequired(false).withLongOpt("imaxdocs").create()); // Clean repository options.addOption( OptionBuilder.hasArg(false).withDescription("Empties the repository before inserting new ones.") .isRequired(false).withLongOpt("iclean").create()); // Use annotator options.addOption(OptionBuilder.hasArgs() .withDescription( "List of annotators to use when inserting the documents. (e.g. PennTreeAnnotator).") .isRequired(false).withValueSeparator(',').withLongOpt("iannotators").create()); // Documents folder options.addOption(OptionBuilder.hasArg().withArgName("folder") .withDescription("The folder that contains the documens to insert.").isRequired(false) .withLongOpt("idocs").create()); // Initializing the line parser CommandLineParser parser = new PosixParser(); try { line = parser.parse(options, args); } catch (ParseException e) { printHelp(options); return; } // Validate that either inserting or an operation are given if (!line.hasOption("I") && !line.hasOption("O")) { System.out.println("One of the options -I or -O must be present."); printHelp(options); return; } repositoryFolder = line.getOptionValue("repo"); try { if (line.hasOption("I")) { indexing(); } else if (line.hasOption("O")) { operation(); } } catch (ParseException e) { System.out.println(e.getMessage()); printHelp(options); return; } System.out.println("TML finished successfully in " + (System.nanoTime() - time) * 10E-9 + " seconds."); return; }
From source file:com.comcast.oscar.cli.commands.TLVtoJSON.java
/** * Set option parameters for command TLV to JSON display * @return Option// w ww. j a v a 2 s. c o m */ public static final Option OptionParameters() { OptionBuilder.withArgName("TLV"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("tlv2json"); OptionBuilder.withDescription( "View the JSON array of a TLV EX: 030101 (NetworkAccess: Type 3 Length 1 Value 1)."); return OptionBuilder.create("t2j"); }
From source file:com.comcast.oscar.cli.commands.JSONtoTLV.java
/** * Set option parameters for command JSON to TLV display * @return Option/*from www .j a va 2 s. co m*/ */ public static final Option OptionParameters() { OptionBuilder.withArgName("filename"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("json2tlv"); OptionBuilder.withDescription("View the TLV number of a JSON array within the file."); return OptionBuilder.create("j2t"); }
From source file:com.comcast.oscar.cli.commands.OID.java
/** * Set option parameters for command OID * @return Option/*from w w w. j ava 2s . c om*/ */ public static Option OptionParameters() { OptionBuilder.withArgName("[<OID>][<value>][<data type>]"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("OID"); OptionBuilder.withDescription("Insert this OID into a file when compiling. " + "Multiple OIDs can be inserted simultaneously (space delimited). " + "Applicable datatypes: " + BERService.getDataTypeStringList()); return OptionBuilder.create("O"); }
From source file:com.comcast.oscar.cli.commands.TFTPServer.java
/** * Set option parameters for command TFTP Server Address * @return Option//from ww w .j av a 2 s. co m */ public static final Option OptionParameters() { OptionBuilder.withArgName("v4/v6=<tftp address>"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("tftp"); OptionBuilder.withDescription("Add this TFTP server during file compilation. " + "For IPv4 use this format for the argument: v4=<server address>. " + "For IPv6 use this format for the argument: v6=<server address>. " + "Both address versions can be inserted simultaneously (space delimited)."); return OptionBuilder.create("T"); }
From source file:com.comcast.oscar.cli.commands.CVC.java
/** * Set option parameters for command CVC * @return Option/* ww w . j a v a 2s. c om*/ */ public static final Option OptionParameters() { OptionBuilder.withArgName("c/m=<filename>"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("certificate"); OptionBuilder.withDescription("Add this CVC during file compilation. " + "For CoSigner use this format for the argument: c=<filename>. " + "For Manufacturer use this format for the argument: m=<filename>. " + "Both CVCs can be inserted simultaneously (space delimited)."); return OptionBuilder.create("cvc"); }
From source file:com.comcast.oscar.cli.commands.DigitmapInsert.java
/** * Set option parameters for command Digitmap Insert * @return Option//from w w w. j a v a 2 s. c o m */ public static final Option OptionParameters() { OptionBuilder.withArgName("[<filename>][<OID>]"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("digitmap"); OptionBuilder.withDescription("Insert this DigitMap into a file when compiling - PacketCable ONLY. " + "Multiple DigitMaps can be inserted simultaneously (space delimited). " + "OID optional."); return OptionBuilder.create("dm"); }
From source file:com.comcast.oscar.cli.commands.Specification.java
/** * Set option parameters for command Specification * @return Option//from ww w . jav a 2s . c om */ public static final Option OptionParameters() { OptionBuilder.withArgName("d{ocsis}|p{acketcable}|d{po}e> <version"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("spec"); OptionBuilder.withDescription( "Set specification and version of the file to be compiled/decompiled EX: -s d 1.1 (DOCSIS 1.1) / -s p 1.5 (PacketCable 1.5)."); return OptionBuilder.create("s"); }