List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:edu.mines.acmX.exhibit.runner.ModuleManagerRunner.java
@SuppressWarnings("static-access") private static Option optionsUsingManifest() { return OptionBuilder.withLongOpt("manifest") .withDescription("\nUse a custom module manager manifest file. " + "The manifest must specify the default module to load, " + "the location of the modules folder and any configuration files " + "that are needed for the drivers you would like to use.") .hasArg().withArgName("PATH").create(); }
From source file:com.linkedin.databus.util.InteractiveSchemaGeneratorCli.java
@SuppressWarnings("static-access") @Override//from w w w. j a v a 2s .c o m protected void constructCommandLineOptions() { super.constructCommandLineOptions(); Option automaticOption = OptionBuilder.withLongOpt(AUTOMATIC_OPT_NAME).withDescription( "Answer all questions proved through cli automatically and interactive for the rest of the options.") .create(AUTOMATIC_OPT_CHAR); Option checkoutSchemaRegistryOption = OptionBuilder.withLongOpt(CHECKOUT_SCHEMA_REGISTRY_NAME) .withDescription("Use Source Control tool to checkout schema.") .create(CHECKOUT_SCHEMA_REGISTRY_CHAR); Option dbnameOption = OptionBuilder.withLongOpt(DBNAME_OPT_NAME).hasArg().withArgName("db_name") .withDescription("The name of database").create(DBNAME_OPT_CHAR); Option dburlOption = OptionBuilder.withLongOpt(DBURL_OPT_NAME).hasArg().withArgName("url") .withDescription("DB URL to read view/table definitions").create(DBURL_OPT_CHAR); Option fieldsOption = OptionBuilder.withLongOpt(FIELDS_OPT_NAME).hasArg().withArgName("fields") .withDescription("Comma-separated list of table/view fields to include in the schema") .create(FIELDS_OPT_CHAR); Option passwordOption = OptionBuilder.withLongOpt(PASSWORD_OPT_NAME).hasArg().withArgName("password") .withDescription("DB password").create(PASSWORD_OPT_CHAR); Option pkOption = OptionBuilder.withLongOpt(PK_OPT_NAME).hasArg().withArgName("keys") .withDescription("Comma-separated list of primary keys of view/table").create(PK_OPT_CHAR); Option tableOption = OptionBuilder.withLongOpt(TABLE_OPT_NAME).hasArg().withArgName("table_name") .withDescription("The name of the table/view whose schema to generate ").create(TABLE_OPT_CHAR); Option userOption = OptionBuilder.withLongOpt(USER_OPT_NAME).hasArg().withArgName("user") .withDescription("DB username").create(USER_OPT_CHAR); Option schemaRegPathOption = OptionBuilder.withLongOpt(SCHEMA_REGISTRY_PATH_OPT_NAME).hasArg() .withArgName("path").withDescription("The path where to checkout the schema registry") .create(SCHEMA_REGISTRY_PATH_OPT_CHAR); Option numberOverrideOption = OptionBuilder.withLongOpt(NUMBEROVERRIDE_OPT_NAME).hasArg() .withArgName("path") .withDescription( "Override number fields datatype with FLOAT, LONG, INTEGER, DOUBLE. Input as, DB_FIELD_NAME1=FLOAT,DB_FIELD_NAME2=DOUBLE") .create(NUMBEROVERRIDE_OPT_CHAR); Option namespaceOption = OptionBuilder.withLongOpt(NAMESPACE_OPT_NAME).hasArg().withArgName("namespace") .withDescription("The name of namespace prefix").create(NAMESPACE_OPT_CHAR); _cliOptions.addOption(automaticOption); _cliOptions.addOption(checkoutSchemaRegistryOption); _cliOptions.addOption(dbnameOption); _cliOptions.addOption(dburlOption); _cliOptions.addOption(fieldsOption); _cliOptions.addOption(passwordOption); _cliOptions.addOption(pkOption); _cliOptions.addOption(tableOption); _cliOptions.addOption(userOption); _cliOptions.addOption(schemaRegPathOption); _cliOptions.addOption(numberOverrideOption); _cliOptions.addOption(namespaceOption); }
From source file:com.continuent.tungsten.common.security.PasswordManagerCtrl.java
/** * Setup command line options/* w w w . j a v a2s. c o m*/ */ @SuppressWarnings("static-access") private void setupCommandLine() { // --- Options on the command line --- Option help = OptionBuilder.withLongOpt(HELP).withDescription("Displays this message").create(_HELP); Option file = OptionBuilder.withLongOpt(FILE).withArgName("filename").hasArgs() .withDescription("Location of the " + SecurityConf.SECURITY_PROPERTIES_FILE_NAME + " file") .create(_FILE); // Mutually excluding options OptionGroup optionGroup = new OptionGroup(); authenticate = OptionBuilder.withLongOpt(AUTHENTICATE).hasArgs(2).withArgName("username> <password") .withDescription("Authenticates a user with given password").create(_AUTHENTICATE); create = OptionBuilder.withLongOpt(CREATE).hasArgs(2).withArgName("username> <password") .withDescription("Creates or Updates a user").create(_CREATE); Option delete = OptionBuilder.withLongOpt(DELETE).withArgName("username").hasArgs() .withDescription("Deletes a user").create(_DELETE); optionGroup.addOption(authenticate); optionGroup.addOption(create); optionGroup.addOption(delete); optionGroup.setRequired(true); // At least 1 command required Option targetApplication = OptionBuilder.withLongOpt(TARGET_APPLICATION).withArgName("target").hasArgs() .withDescription("Target application: " + getListOfClientApplicationType()) .create(_TARGET_APPLICATION); // --- Options replacing parameters from security.properties --- Option encryptedPassword = OptionBuilder.withLongOpt(ENCRYPTED_PASSWORD).withArgName("encrypt password") .withDescription("Encrypts the password").create(_ENCRYPTED_PASSWORD); Option truststoreLocation = OptionBuilder.withLongOpt(TRUSTSTORE_LOCATION).withArgName("filename").hasArg() .withDescription("Location of the tuststore file").create(_TRUSTSTORE_LOCATION); Option truststorePassword = OptionBuilder.withLongOpt(TRUSTSTORE_PASSWORD).withArgName("password").hasArg() .withDescription("Password for the truststore file").create(_TRUSTSTORE_PASSWORD); Option keystoreLocation = OptionBuilder.withLongOpt(KEYSTORE_LOCATION).withArgName("filename").hasArg() .withDescription("Location of the keystore file").create(_KEYSTORE_LOCATION); Option keystorePassword = OptionBuilder.withLongOpt(KEYSTORE_PASSWORD).withArgName("password").hasArg() .withDescription("Password for the keystore file").create(_KEYSTORE_PASSWORD); Option passwordFileLocation = OptionBuilder.withLongOpt(PASSWORD_FILE_LOCATION).withArgName("filename") .hasArg().withDescription("Location of the password file").create(_PASSWORD_FILE_LOCATION); // --- Add options to the list --- // --- Help this.helpOptions.addOption(help); // --- Program command line options this.options.addOptionGroup(optionGroup); this.options.addOption(file); this.options.addOption(help); this.options.addOption(encryptedPassword); this.options.addOption(truststoreLocation); this.options.addOption(truststorePassword); this.options.addOption(keystoreLocation); this.options.addOption(keystorePassword); this.options.addOption(passwordFileLocation); this.options.addOption(targetApplication); }
From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java
/** * Creates and adds a non-word infile option to a given {@link Options} * object.//from w ww .ja v a 2s .c o m * * @param options * The <code>Options</code> object to add to. */ private static void addNonwordInfileOption(final Options options) { OptionBuilder.withLongOpt(NONWORD_INFILE_KEY_LONG); OptionBuilder.withDescription(NONWORD_INFILE_DESCR); OptionBuilder.hasArg(); OptionBuilder.withArgName(INFILE_ARG_NAME); OptionBuilder.withType(File.class); final Option nonwordInfile = OptionBuilder.create(NONWORD_INFILE_KEY); options.addOption(nonwordInfile); }
From source file:com.basho.contact.ContactConsole.java
@SuppressWarnings("static-access") public static CommandLine processArgs(String[] args) { Options options = new Options(); Option help = OptionBuilder.withLongOpt("help").withDescription("Print this list of commands").create(); Option nocolor = OptionBuilder.withLongOpt("nocolor").withDescription("Don't use color output").create(); Option noconfig = OptionBuilder.withLongOpt("noconfig").withDescription("Don't read ~/.contact.config") .create();/*from w w w . j a v a2 s . c om*/ Option infile = OptionBuilder.withLongOpt("infile").withDescription("Read input from file and exit") .hasArg().withArgName("filename").create(); Option nosignals = OptionBuilder.withLongOpt("nosignals") .withDescription("Don't catch the Ctrl-C (INT) signal").create(); options.addOption(help); options.addOption(nocolor); options.addOption(noconfig); options.addOption(infile); options.addOption(nosignals); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("contact", options); System.exit(0); } return line; } catch (ParseException exp) { System.err.println("Error processing command line args: " + exp.getMessage()); System.exit(-1); } return null; }
From source file:com.dtolabs.rundeck.ExpandRunServer.java
@SuppressWarnings("static-access") public ExpandRunServer() { Option baseDir = OptionBuilder.withLongOpt("basedir").hasArg().withDescription("The basedir") .withArgName("PATH").create('b'); Option serverDir = OptionBuilder.withLongOpt("serverdir").hasArg() .withDescription("The base directory for the server").withArgName("PATH").create(); Option binDir = OptionBuilder.withLongOpt("bindir").hasArg().withArgName("PATH") .withDescription("The install directory for the tools used by users.").create('x'); Option sbinDir = OptionBuilder.withLongOpt("sbindir").hasArg().withArgName("PATH") .withDescription("The install directory for the tools used by administrators.").create('s'); Option configDir = OptionBuilder.withLongOpt("configdir").hasArg().withArgName("PATH") .withDescription("The location of the configuration.").create('c'); Option dataDir = OptionBuilder.withLongOpt("datadir").hasArg().withArgName("PATH") .withDescription("The location of Rundeck's runtime data.").create(); Option projectDir = OptionBuilder.withLongOpt("projectdir").hasArg().withArgName("PATH") .withDescription("The location of Rundeck's project data.").create('p'); Option help = OptionBuilder.withLongOpt("help").withDescription("Display this message.").create('h'); Option debugFlag = OptionBuilder.withDescription("Show debug information").create('d'); Option skipInstall = OptionBuilder.withLongOpt(FLAG_SKIPINSTALL) .withDescription("Skip the extraction of the utilities from the launcher.").create(); Option installonly = OptionBuilder.withLongOpt(FLAG_INSTALLONLY) .withDescription("Perform installation only and do not start the server.").create(); options.addOption(baseDir);// w ww .j a v a2 s.c o m options.addOption(dataDir); options.addOption(serverDir); options.addOption(binDir); options.addOption(sbinDir); options.addOption(configDir); options.addOption(help); options.addOption(debugFlag); options.addOption(skipInstall); options.addOption(installonly); options.addOption(projectDir); debug = Boolean.getBoolean(SYS_PROP_RUNDECK_LAUNCHER_DEBUG); rewrite = Boolean.getBoolean(SYS_PROP_RUNDECK_LAUNCHER_REWRITE); useJaas = null == System.getProperty(SYS_PROP_RUNDECK_JAASLOGIN) || Boolean.getBoolean(SYS_PROP_RUNDECK_JAASLOGIN); runClassName = RUN_SERVER_CLASS; thisJar = thisJarFile(); //load jar attributes final Attributes mainAttributes = getJarMainAttributes(); if (null == mainAttributes) { throw new RuntimeException("Unable to load attributes"); } versionString = mainAttributes.getValue(RUNDECK_VERSION); if (null != versionString) { DEBUG("Rundeck version: " + versionString); } else { throw new RuntimeException("Jar file attribute not found: " + RUNDECK_VERSION); } runClassName = mainAttributes.getValue(RUNDECK_START_CLASS); if (null == runClassName) { throw new RuntimeException("Jar file attribute not found: " + RUNDECK_START_CLASS); } jettyLibsString = mainAttributes.getValue(RUNDECK_JETTY_LIBS); if (null == jettyLibsString) { throw new RuntimeException("Jar file attribute not found: " + RUNDECK_JETTY_LIBS); } jettyLibPath = mainAttributes.getValue(RUNDECK_JETTY_LIB_PATH); if (null == jettyLibPath) { throw new RuntimeException("Jar file attribute not found: " + RUNDECK_JETTY_LIB_PATH); } }
From source file:net.jsign.PESignerCLI.java
PESignerCLI() { options = new Options(); options.addOption(OptionBuilder.hasArg().withLongOpt("keystore").withArgName("FILE") .withDescription("The keystore file").withType(File.class).create('s')); options.addOption(OptionBuilder.hasArg().withLongOpt("storepass").withArgName("PASSWORD") .withDescription("The password to open the keystore").create()); options.addOption(OptionBuilder.hasArg().withLongOpt("storetype").withArgName("TYPE").withDescription( "The type of the keystore:\n- JKS: Java keystore (.jks files)\n- PKCS12: Standard PKCS#12 keystore (.p12 or .pfx files)\n") .create());/*from w ww . j a v a 2 s . c o m*/ options.addOption(OptionBuilder.hasArg().withLongOpt("alias").withArgName("NAME") .withDescription("The alias of the certificate used for signing in the keystore.").create('a')); options.addOption(OptionBuilder.hasArg().withLongOpt("keypass").withArgName("PASSWORD").withDescription( "The password of the private key. When using a keystore, this parameter can be omitted if the keystore shares the same password.") .create()); options.addOption(OptionBuilder.hasArg().withLongOpt("keyfile").withArgName("FILE") .withDescription("The file containing the private key. Only PVK files are supported. ") .withType(File.class).create()); options.addOption(OptionBuilder.hasArg().withLongOpt("certfile").withArgName("FILE") .withDescription("The file containing the PKCS#7 certificate chain\n(.p7b or .spc files).") .withType(File.class).create('c')); options.addOption(OptionBuilder.hasArg().withLongOpt("keyfile").withArgName("FILE") .withDescription("The file containing the private key. Only PVK files are supported. ") .withType(File.class).create()); options.addOption(OptionBuilder.hasArg().withLongOpt("alg").withArgName("ALGORITHM") .withDescription("The digest algorithm (SHA-1 or SHA-256)").create('d')); options.addOption(OptionBuilder.hasArg().withLongOpt("tsaurl").withArgName("URL") .withDescription("The URL of the timestamping authority.").create('t')); options.addOption(OptionBuilder.hasArg().withLongOpt("tsmode").withArgName("MODE") .withDescription("The timestamping mode (RFC3161 or Authenticode)").create('m')); options.addOption(OptionBuilder.hasArg().withLongOpt("name").withArgName("NAME") .withDescription("The name of the application").create('n')); options.addOption(OptionBuilder.hasArg().withLongOpt("url").withArgName("URL") .withDescription("The URL of the application").create('u')); options.addOption(OptionBuilder.withLongOpt("help").withDescription("Print the help").create('h')); }
From source file:com.conversantmedia.mapreduce.tool.ToolContext.java
/** * Re-parse our options using the properties from the specified conf file. * @param properties the command line override properties * @param args command line arguments * @return any left-over command line arguments * that haven't been parsed. This method sets up and parses * only the option file argument, so the return would be everything * from the command line args except the --file if provided. * @throws ParseException if unable to parse the command line options * @throws IOException if unable to read the file *///from w w w .j a v a 2 s. c o m @SuppressWarnings("static-access") protected String[] getConfigOverrides(Properties properties, String[] args) throws ParseException, IOException { // Parse with our config option only... Options options = new Options(); options.addOption(OptionBuilder.withLongOpt(OPTION_OPTIONS_FILE) .withDescription("Configuration file of key/value pairs with option overrides.").withArgName("file") .hasArg().create()); Parser parser = new IgnoreUnknownParser(); CommandLine line = parser.parse(options, args, true); if (line.hasOption(OPTION_OPTIONS_FILE)) { File confFile = new File(line.getOptionValue(OPTION_OPTIONS_FILE)); if (!confFile.exists()) { throw new IllegalArgumentException("Configuration file not found."); } Reader reader = null; try { reader = new FileReader(confFile); properties.load(reader); } finally { IOUtils.closeQuietly(reader); } } return line.getArgs(); }
From source file:com.virtualparadigm.packman.cli.Main.java
private static Options buildCommandLineOptions() { Options cliOptions = new Options(); OptionBuilder.withArgName(CMD_OPTION_LONG_PACKAGE_NAME); OptionBuilder.withLongOpt(CMD_OPTION_LONG_PACKAGE_NAME); OptionBuilder.withDescription("package name"); OptionBuilder.hasArg(true);/*from w ww . j ava 2 s . com*/ OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_PACKAGE_NAME)); OptionBuilder.withArgName(CMD_OPTION_LONG_PACKAGE_VERSION); OptionBuilder.withLongOpt(CMD_OPTION_LONG_PACKAGE_VERSION); OptionBuilder.withDescription("package version"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_PACKAGE_VERSION)); OptionBuilder.withArgName(CMD_OPTION_LONG_PACKAGE_FILE); OptionBuilder.withLongOpt(CMD_OPTION_LONG_PACKAGE_FILE); OptionBuilder.withDescription("package file"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_PACKAGE_FILE)); OptionBuilder.withArgName(CMD_OPTION_LONG_LICENSE_FILE); OptionBuilder.withLongOpt(CMD_OPTION_LONG_LICENSE_FILE); OptionBuilder.withDescription("license file"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_LICENSE_FILE)); OptionBuilder.withArgName(CMD_OPTION_LONG_AUTORUN_INSTALL_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_AUTORUN_INSTALL_DIR); OptionBuilder.withDescription("install directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_AUTORUN_INSTALL_DIR)); OptionBuilder.withArgName(CMD_OPTION_LONG_AUTORUN_UNINSTALL_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_AUTORUN_UNINSTALL_DIR); OptionBuilder.withDescription("uninstall directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_AUTORUN_UNINSTALL_DIR)); OptionBuilder.withArgName(CMD_OPTION_LONG_NEW_STATE_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_NEW_STATE_DIR); OptionBuilder.withDescription("new state directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_NEW_STATE_DIR)); OptionBuilder.withArgName(CMD_OPTION_LONG_OLD_STATE_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_OLD_STATE_DIR); OptionBuilder.withDescription("old state directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_OLD_STATE_DIR)); OptionBuilder.withArgName(CMD_OPTION_LONG_DEV_MODE); OptionBuilder.withLongOpt(CMD_OPTION_LONG_DEV_MODE); OptionBuilder.withDescription("development mode"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_DEV_MODE)); OptionBuilder.withArgName(CMD_OPTION_LONG_TARGET_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_TARGET_DIR); OptionBuilder.withDescription("target directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_TARGET_DIR)); OptionBuilder.withArgName(CMD_OPTION_LONG_DATA_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_DATA_DIR); OptionBuilder.withDescription("jpackage manager data directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_DATA_DIR)); OptionBuilder.withArgName(CMD_OPTION_LONG_LOCAL_CONFIG_FILE); OptionBuilder.withLongOpt(CMD_OPTION_LONG_LOCAL_CONFIG_FILE); OptionBuilder.withDescription("local install configuration values"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_LOCAL_CONFIG_FILE)); OptionBuilder.withArgName(CMD_OPTION_LONG_TEMP_DIR); OptionBuilder.withLongOpt(CMD_OPTION_LONG_TEMP_DIR); OptionBuilder.withDescription("temp directory"); OptionBuilder.hasArg(true); OptionBuilder.isRequired(false); cliOptions.addOption(OptionBuilder.create(CMD_OPTION_LONG_TEMP_DIR)); return cliOptions; }
From source file:ca.uqac.info.trace.XML.Hadoop.HadoopTraceGenerator.java
/** * Sets up the options for the command line parser * @return The options/*from www . j a v a 2s. co m*/ */ @SuppressWarnings("static-access") private static Options setupOptions() { Options options = new Options(); Option opt; opt = OptionBuilder.withLongOpt("help").withDescription("Display command line usage").create("h"); options.addOption(opt); opt = OptionBuilder.withLongOpt("FileWriter").withArgName("x").hasArg() .withDescription("File who contain the XML generated").create("f"); options.addOption(opt); opt = OptionBuilder.withLongOpt("generator").withArgName("name").hasArg() .withDescription("Use generator name").create("g"); options.addOption(opt); opt = OptionBuilder.withLongOpt("Size").withArgName("n").hasArg() .withDescription("Size maximum of the output XML File (in bytes)").create("s"); options.addOption(opt); opt = OptionBuilder.withLongOpt("Type").withArgName("t").hasArg() .withDescription("Type of the variables of the XML Trace (Numbers , Letters, Both)").create("t"); options.addOption(opt); opt = OptionBuilder.withLongOpt("Conditions").withArgName("x").hasArg() .withDescription("File who contains the variable conditions").create("c"); options.addOption(opt); opt = OptionBuilder.withLongOpt("Depth").withArgName("x").hasArg().withDescription("Depth of the Traces") .create("d"); options.addOption(opt); opt = OptionBuilder.withLongOpt("VariableDepth").withArgName("x").hasArg() .withDescription("Depth of the Variables").create("v"); options.addOption(opt); opt = OptionBuilder.withLongOpt("DepthValue").withArgName("x").hasArg() .withDescription("Depth of the values").create("w"); options.addOption(opt); opt = OptionBuilder.withLongOpt("verbosity").withArgName("x").hasArg() .withDescription("Set verbosity level to x (0 = nothing)").create("z"); options.addOption(opt); return options; }