List of usage examples for org.apache.commons.cli Option setArgName
public void setArgName(String argName)
From source file:org.multicore_association.measure.cycle.writeback.ParameterParser.java
private Options generateOpts() { Option optArch; Option optCmnInstSet;/* w w w .ja v a2 s . c o m*/ Option optShimSchema; Option optRecursive; Option optHelp; Option optInputShim; Option optOutputShim; Option optCsvDir; optArch = new Option(ARCH_NAME_OPT, ARCH_NAME_LOPT, true, ARCH_NAME_DESC); optArch.setArgName(ARCH_NAME_ARGNAME); optCmnInstSet = new Option(INSTSET_NAME_OPT, INSTSET_NAME_LOPT, true, INSTSET_NAME_DESC); optCmnInstSet.setArgName(INSTSET_NAME_ARGNAME); optShimSchema = new Option(SHIM_SCHEMA_OPT, SHIM_SCHEMA_LOPT, true, SHIM_SCHEMA_DESC); optShimSchema.setArgName(SHIM_SCHEMA_ARGNAME); optRecursive = new Option(RECURSIVE_OPT, RECURSIVE_LOPT, false, RECURSIVE_DESC); optHelp = new Option(PRINTHELP_OPT, PRINTHELP_LOPT, false, PRINTHELP_DESC); optInputShim = new Option(INPUT_SHIM_OPT, INPUT_SHIM_LOPT, true, INPUT_SHIM_DESC); optInputShim.setArgName(INPUT_SHIM_ARGNAME); // optInputShim.setRequired(true); optOutputShim = new Option(OUTPUT_SHIM_OPT, OUTPUT_SHIM_LOPT, true, OUTPUT_SHIM_DESC); optOutputShim.setArgName(OUTPUT_SHIM_ARGNAME); optOutputShim.setRequired(true); optCsvDir = new Option(CSV_DIR_OPT, CSV_DIR_LOPT, true, CSV_DIR_DESC); optCsvDir.setArgName(CSV_DIR_ARGNAME); optCsvDir.setRequired(false); Options opts = new Options(); opts.addOption(optArch); opts.addOption(optCmnInstSet); opts.addOption(optShimSchema); opts.addOption(optRecursive); opts.addOption(optHelp); opts.addOption(optInputShim); opts.addOption(optOutputShim); opts.addOption(optCsvDir); return opts; }
From source file:org.onebusaway.quickstart.bootstrap.WebappBootstrapMain.java
private static Options createOptions() { Options options = new Options(); options.addOption(ARG_PORT, true, "port (default=8080)"); options.addOption(WebappCommon.ARG_BUILD, false, ""); options.addOption(WebappCommon.ARG_GTFS_PATH, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_TRIP_UPDATES_URL, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_VEHICLE_POSITIONS_URL, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_ALERTS_URL, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_REFRESH_INTERVAL, true, ""); Option pOption = new Option("P", "use value for given property"); pOption.setArgName("beanName.beanProperty=value"); pOption.setArgs(2);/*from ww w . j a v a 2 s . c o m*/ pOption.setValueSeparator('='); options.addOption(pOption); return options; }
From source file:org.onebusaway.transit_data_federation.bundle.FederatedTransitDataBundleCreatorMain.java
protected void buildOptions(Options options) { options.addOption(ARG_SKIP_TO, true, ""); options.addOption(ARG_ONLY, true, ""); options.addOption(ARG_SKIP, true, ""); options.addOption(ARG_INCLUDE, true, ""); options.addOption(ARG_ONLY_IF_DNE, false, ""); options.addOption(ARG_DATASOURCE_DRIVER_CLASS_NAME, true, ""); options.addOption(ARG_DATASOURCE_URL, true, ""); options.addOption(ARG_DATASOURCE_USERNAME, true, ""); options.addOption(ARG_DATASOURCE_PASSWORD, true, ""); options.addOption(ARG_BUNDLE_KEY, true, ""); options.addOption(ARG_RANDOMIZE_CACHE_DIR, false, ""); options.addOption(ARG_ADDITIONAL_RESOURCES_DIRECTORY, true, ""); options.addOption(ARG_OSM, true, ""); Option dOption = new Option("D", "use value for given property"); dOption.setArgName("property=value"); dOption.setArgs(2);/*from ww w. java2s.co m*/ dOption.setValueSeparator('='); options.addOption(dOption); Option pOption = new Option("P", "use value for given property"); pOption.setArgName("beanName.beanProperty=value"); pOption.setArgs(2); pOption.setValueSeparator('='); options.addOption(pOption); }
From source file:org.openbel.framework.tools.BelCheck.java
/** * {@inheritDoc}//w w w .ja va 2s .co m */ @Override public List<Option> getCommandLineOptions() { final List<Option> ret = new LinkedList<Option>(); ret.add(new Option(null, PEDANTIC_OPTION, false, CHECK_PEDANTIC)); ret.add(new Option(null, PERMISSIVE_OPTION, false, CHECK_PERMISSIVE)); ret.add(new Option(QUIET_OPTION, "quiet", false, CHECK_QUIET)); ret.add(new Option(null, SUMMARY_OPTION, false, CHECK_SUMMARY)); Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, SYSTEM_CONFIG_PATH); o.setArgName(ARG_SYSCFG); ret.add(o); return ret; }
From source file:org.openbel.framework.tools.CacheManager.java
/** * {@inheritDoc}/*from w ww . j a v a 2 s .c om*/ */ @Override public List<Option> getCommandLineOptions() { final List<Option> ret = new LinkedList<Option>(); String help; help = LIST_CACHE; ret.add(new Option(LIST_CACHE_OPTION, "list-cache", false, help)); help = LOAD_RESOURCE; ret.add(new Option(CACHE_RESOURCE_OPTION, "cache-resource", true, help)); help = LOAD_INDEX_FILE; ret.add(new Option(CACHE_INDEX_FILE, "index-file", true, help)); help = LOAD_INDEX_FROM_SYSCONFIG; ret.add(new Option(CACHE_SYSCONFIG_FILE_OPTION, "sysconfig-index-file", false, help)); help = PURGE_CACHE; ret.add(new Option(PURGE_CACHE_OPTION, "purge", false, help)); help = HASH; ret.add(new Option(GENERATE_CHECKSUM_OPTION, "generate-checksum", true, help)); help = SYSTEM_CONFIG_PATH; Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, help); o.setArgName(ARG_SYSCFG); ret.add(o); return ret; }
From source file:org.openbel.framework.tools.kamstore.KamComparator.java
@Override public List<Option> getCommandLineOptions() { final List<Option> options = new LinkedList<Option>(); options.add(new Option(null, LONG_OPT_DEBUG, false, "Enables debug mode. This mode outputs additional debug information " + "as the application runs.")); options.add(new Option(SHRT_OPT_HELP, LONG_OPT_HELP, false, "Enables help mode. This mode shows the help information.")); options.add(new Option("l", "list", false, "Lists the KAMs stored in the KAMStore.")); final Option oOpt = new Option("o", "output-file", true, "Optional. If present, indicates the name of the output file " + "to write the KAM comparisions to in XHTML format."); oOpt.setArgName("output filename"); options.add(oOpt);/* w w w .j a v a 2 s .co m*/ options.add(new Option(null, "no-preserve", false, "Optional. If present, if a file exist with the same name as the output " + "file then that file will be overwritten.")); final Option sOpt = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, false, SYSTEM_CONFIG_PATH); sOpt.setArgName(ARG_SYSCFG); options.add(sOpt); options.add(new Option(SHORT_OPT_VERBOSE, LONG_OPT_VERBOSE, false, VERBOSE_HELP)); return options; }
From source file:org.openbel.framework.tools.kamstore.KamManager.java
@Override public List<Option> getCommandLineOptions() { List<Option> options = new LinkedList<Option>(); // Add the long options that serve as the commands for (Command c : Command.values()) { if (c != Command.HELP) { options.add(new Option(null, c.getAlias(), false, "The " + c.getAlias() + " command. " + commandToUsageHelp.get(c))); }//w w w. ja v a 2s. c o m } // -f/--force/--no-preserve used for the import, export, and rename commands final String noPreserveHelp = "Optional. Used with the summarize or export commands, if a file with the same name " + "as the output file already exists then it will be overwritten. " + "If used with the import command, if a KAM with the same name as " + "being imported already exists in the KAM store, it will be " + "overwritten. If used with the rename command, if the new name for a KAM " + "is also the name of another KAM in the KAM store, then that KAM " + "will be overwritten.\n" + "The default is always to preserve the existing file or KAM and " + "generate a warning."; options.add(new Option("f", "force", false, "Identical to --no-preserve.")); options.add(new Option(null, LONG_OPT_NO_PRESERVE, false, noPreserveHelp)); // -o/--output-file used to set the file to output XHTML output (for the // summarize command, for example) final String outputFileHelp = "Optional. If present, it indicates the name of the output file " + "to write the summary to. The file will be written as XHTML."; options.add(new Option("o", "output-file", true, outputFileHelp)); // -p/--password used for the import and export commands final String passwordHelp = "Optional. With the import command, the password is used to decrypt the " + "portable KAM file if the file was encrypted during export. " + "With the export command, the password is used to encrypt the " + "portable KAM file. This same password must be used to import " + "the portable KAM with the " + getApplicationShortName() + " import command.\n" + "The default is to not encrypt or decrypt."; options.add(new Option("p", "password", true, passwordHelp)); // -t/--type used for the import and export commands final String typeHelp = "With the import command, this option specifies the format of the imported KAM file. " + "By default, " + getApplicationShortName() + " infers the format of the KAM file by " + "its extension (" + KAM_EXTENSION + ", " + XGMML_EXTENSION + ", or " + N3_EXTENSION + ").\n" + "With the export command, this option specifies the type of export file to generate. " + "If XGMML the KAM will be exported in XGMML format. If RDF " + "the KAM will be exported as an RDF using N3 format. If KAM " + "is specified, the KAM will be exported in a portable binary " + "format that can be subsequently imported to another KAM store " + "using the " + getApplicationShortName() + " import command. The default is to export to " + "a portable KAM format."; options.add(new Option("t", "type", true, typeHelp)); // Add the options common to all commands: options.add(new Option("q", "quiet", false, "Enables quiet mode. This mode outputs very little additional information " + "as the application runs.\n" + "The default is to disable quiet mode.")); final Option sOpt = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, SYSTEM_CONFIG_PATH); sOpt.setArgName(ARG_SYSCFG); options.add(sOpt); // The base class CommandLineApplication will add the --debug, -h/--help, // and -v/--verbose options. return options; }
From source file:org.openbel.framework.tools.PhaseApplication.java
/** * Returns a list of phase-agnostic command-line options. * * @return List of options//from w ww .ja v a2s.c om */ @Override public List<Option> getCommandLineOptions() { final List<Option> ret = new LinkedList<Option>(); String help; help = TIME_HELP; ret.add(new Option(SHORT_OPT_TIME, LONG_OPT_TIME, false, help)); help = WARNINGS_AS_ERRORS; ret.add(new Option(null, LONG_OPT_PEDANTIC, false, help)); help = SYSTEM_CONFIG_PATH; Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, help); o.setArgName(ARG_SYSCFG); ret.add(o); return ret; }
From source file:org.openbel.framework.tools.PhaseOneApplication.java
/** * {@inheritDoc}/*from w w w . ja v a 2 s. c o m*/ */ @Override public List<Option> getCommandLineOptions() { List<Option> options = super.getCommandLineOptions(); String help; Option o; help = PHASE_1_INPUT_PATH; o = new Option(SHORT_OPT_IN_PATH, LONG_OPT_IN_PATH, true, help); o.setArgName("path"); options.add(o); help = PHASE_1_INPUT_FILE; o = new Option(INFILE_SHORT_OPT, INFILE_LONG_OPT, true, help); o.setArgName("filename"); options.add(o); help = PHASE_1_DISABLE_NESTED_STMTS; o = new Option(null, NO_NS_LONG_OPT, false, help); options.add(o); help = PHASE_1_NO_SEMANTICS; o = new Option(null, NO_SEMANTIC_CHECK, false, help); options.add(o); help = PHASE_1_NO_SYNTAX; o = new Option(null, NO_SYNTAX_CHECK, false, help); options.add(o); return options; }
From source file:org.ow2.proactive.authentication.crypto.CreateCredentials.java
/** * Entry point/*from w ww .j a v a2s .c o m*/ * * @see org.ow2.proactive.authentication.crypto.Credentials * @param args arguments, try '-h' for help * @throws IOException * @throws ParseException * */ public static void main(String[] args) throws IOException, ParseException { SecurityManagerConfigurator.configureSecurityManager( CreateCredentials.class.getResource("/all-permissions.security.policy").toString()); Console console = System.console(); /** * default values */ boolean interactive = true; String pubKeyPath = null; PublicKey pubKey = null; String login = null; String pass = null; String keyfile = null; String cipher = "RSA/ECB/PKCS1Padding"; String path = Credentials.getCredentialsPath(); String rm = null; String scheduler = null; String url = null; Options options = new Options(); Option opt = new Option("h", "help", false, "Display this help"); opt.setRequired(false); options.addOption(opt); OptionGroup group = new OptionGroup(); group.setRequired(false); opt = new Option("F", "file", true, "Public key path on the local filesystem [default:" + Credentials.getPubKeyPath() + "]"); opt.setArgName("PATH"); opt.setArgs(1); opt.setRequired(false); group.addOption(opt); opt = new Option("R", "rm", true, "Request the public key to the Resource Manager at URL"); opt.setArgName("URL"); opt.setArgs(1); opt.setRequired(false); group.addOption(opt); opt = new Option("S", "scheduler", true, "Request the public key to the Scheduler at URL"); opt.setArgName("URL"); opt.setArgs(1); opt.setRequired(false); group.addOption(opt); options.addOptionGroup(group); opt = new Option("l", "login", true, "Generate credentials for this specific user, will be asked interactively if not specified"); opt.setArgName("LOGIN"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option("p", "password", true, "Use this password, will be asked interactively if not specified"); opt.setArgName("PWD"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option("k", "keyfile", true, "Use specified ssh private key, asked interactively if specified without PATH, not specified otherwise."); opt.setArgName("PATH"); opt.setOptionalArg(true); opt.setRequired(false); options.addOption(opt); opt = new Option("o", "output", true, "Output the resulting credentials to the specified file [default:" + path + "]"); opt.setArgName("PATH"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option("c", "cipher", true, "Use specified cipher parameters, need to be compatible with the specified key [default:" + cipher + "]"); opt.setArgName("PARAMS"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(newline + "ERROR : " + e.getMessage() + newline); System.out.println("type -h or --help to display help screen"); System.exit(1); } if (cmd.hasOption("help")) { displayHelp(options); } if (cmd.hasOption("file")) { pubKeyPath = cmd.getOptionValue("file"); } if (cmd.hasOption("rm")) { rm = cmd.getOptionValue("rm"); } if (cmd.hasOption("scheduler")) { scheduler = cmd.getOptionValue("scheduler"); } if (cmd.hasOption("login")) { login = cmd.getOptionValue("login"); } if (cmd.hasOption("password")) { pass = cmd.getOptionValue("password"); } if (cmd.hasOption("keyfile") && cmd.getOptionValues("keyfile") != null) { keyfile = cmd.getOptionValue("keyfile"); } if (cmd.hasOption("output")) { path = cmd.getOptionValue("output"); } if (cmd.hasOption("cipher")) { cipher = cmd.getOptionValue("cipher"); } int acc = 0; if (pubKeyPath != null) { acc++; } if (scheduler != null) { url = Connection.normalize(scheduler) + "SCHEDULER"; acc++; } if (rm != null) { url = Connection.normalize(rm) + "RMAUTHENTICATION"; acc++; } if (acc > 1) { System.out.println("--rm, --scheduler and --file arguments cannot be combined."); System.out.println("try -h for help."); System.exit(1); } if (url != null) { try { Connection<AuthenticationImpl> conn = new Connection<AuthenticationImpl>(AuthenticationImpl.class) { public Logger getLogger() { return Logger.getLogger("pa.scheduler.credentials"); } }; AuthenticationImpl auth = conn.connect(url); pubKey = auth.getPublicKey(); } catch (Exception e) { System.err.println("ERROR : Could not retrieve public key from '" + url + "'"); e.printStackTrace(); System.exit(3); } System.out.println("Successfully obtained public key from " + url + newline); } else if (pubKeyPath != null) { try { pubKey = Credentials.getPublicKey(pubKeyPath); } catch (KeyException e) { System.err .println("ERROR : Could not retrieve public key from '" + pubKeyPath + "' (no such file)"); System.exit(4); } } else { System.out.println("No public key specified, attempting to retrieve it from default location."); pubKeyPath = Credentials.getPubKeyPath(); try { pubKey = Credentials.getPublicKey(pubKeyPath); } catch (KeyException e) { System.err .println("ERROR : Could not retrieve public key from '" + pubKeyPath + "' (no such file)"); System.exit(5); } } if (login != null && pass != null && (!cmd.hasOption("keyfile") || cmd.getOptionValues("keyfile") != null)) { System.out.println("Running in non-interactive mode." + newline); interactive = false; } else { System.out.println("Running in interactive mode."); } if (interactive) { System.out.println("Please enter Scheduler credentials,"); System.out.println("they will be stored encrypted on disk for future logins." + newline); System.out.print("login: "); if (login == null) { login = console.readLine(); } else { System.out.println(login); } System.out.print("password: "); if (pass == null) { pass = new String(console.readPassword()); } else { System.out.println("*******"); } System.out.print("keyfile: "); if (!cmd.hasOption("keyfile")) { System.out.println("no key file specified"); } else if (cmd.hasOption("keyfile") && cmd.getOptionValues("keyfile") != null) { System.out.println(keyfile); } else { keyfile = console.readLine(); } } try { CredData credData; if (keyfile != null && keyfile.length() > 0) { byte[] keyfileContent = FileToBytesConverter.convertFileToByteArray(new File(keyfile)); credData = new CredData(CredData.parseLogin(login), CredData.parseDomain(login), pass, keyfileContent); } else { System.out.println("--> Ignoring keyfile, credential does not contain SSH key"); credData = new CredData(CredData.parseLogin(login), CredData.parseDomain(login), pass); } Credentials cred = Credentials.createCredentials(credData, pubKey, cipher); cred.writeToDisk(path); } catch (FileNotFoundException e) { System.err.println("ERROR : Could not retrieve ssh private key from '" + keyfile + "' (no such file)"); System.exit(6); } catch (Throwable t) { t.printStackTrace(); System.exit(7); } System.out.println("Successfully stored encrypted credentials on disk at :"); System.out.println("\t" + path); System.exit(0); }