List of usage examples for org.apache.commons.cli Option setArgs
public void setArgs(int num)
From source file:com.oneops.boo.BooCli.java
/** * Instantiates a new boo cli./*www. j a v a2s . c o m*/ */ public BooCli() { Option help = new Option("h", "help", false, "show help."); Option create = Option.builder("c").longOpt("create").desc( "Create a new Assembly specified by -f. If Assembly automatic naming is enabled, each invocation will create a new Assembly.") .build(); Option update = Option.builder("u").longOpt("update").desc("Update configurations specified by -f.") .build(); Option status = Option.builder("s").longOpt("status").desc("Get status of deployments specified by -f") .build(); Option config = Option.builder("f").longOpt("config-file").argName("FILE").hasArg() .desc("Use specified Boo YAML file").build(); Option cleanup = Option.builder("r").longOpt("remove") .desc("Remove all deployed configurations specified by -f").build(); Option list = Option.builder("l").longOpt("list").numberOfArgs(1).optionalArg(Boolean.TRUE) .desc("Return a list of instances applicable to the identifier provided..").build(); Option force = Option.builder().longOpt("force").desc("Do not prompt for --remove").build(); Option nodeploy = Option.builder().longOpt("no-deploy").desc("Create assembly without deployments").build(); Option getIps = Option.builder().longOpt("get-ips").argName("environment> <compute-class") .desc("Get IPs of deployed nodes specified by -f; Args are optional.").build(); getIps.setOptionalArg(true); getIps.setArgs(Option.UNLIMITED_VALUES); Option retry = Option.builder().longOpt("retry").desc("Retry deployments of configurations specified by -f") .build(); Option quiet = Option.builder().longOpt("quiet").desc("Silence the textual output.").build(); Option assembly = Option.builder("a").longOpt("assembly").hasArg().desc("Override the assembly name.") .build(); Option action = Option.builder().longOpt("procedure").numberOfArgs(3).optionalArg(Boolean.TRUE) .argName("platform> <component> <action") .desc("Execute actions. Use 'list' as an action to show available actions.").build(); Option procedureArguments = Option.builder().longOpt("procedure-arguments").argName("arglist").hasArg() .desc("Arguments to pass to the procedure call. Example: '{\"backup_type\":\"incremental\"}'") .build(); Option instanceList = Option.builder().longOpt("procedure-instances").argName("instanceList").hasArg().desc( "Comma-separated list of component instance names. 'list' to show all available component instances.") .build(); Option stepSize = Option.builder().longOpt("procedure-step-size").argName("size").hasArg() .desc("Percent of nodes to perform procedure on, default is 100.").build(); Option comment = Option.builder("m").longOpt("message").argName("description").hasArg() .desc("Customize the comment for deployments").build(); Option view = Option.builder("v").longOpt("view").desc("View interpolated Boo YAML template").build(); Option profile = Option.builder("p").longOpt("profile").argName("PROFILE").hasArg() .desc("Choose specific profile from ~/.boo/config").build(); options.addOption(help); options.addOption(config); options.addOption(create); options.addOption(update); options.addOption(status); options.addOption(list); options.addOption(cleanup); options.addOption(getIps); options.addOption(retry); options.addOption(quiet); options.addOption(force); options.addOption(nodeploy); options.addOption(assembly); options.addOption(action); options.addOption(procedureArguments); options.addOption(instanceList); options.addOption(stepSize); options.addOption(comment); options.addOption(view); options.addOption(profile); }
From source file:br.edu.ufcg.lsd.oursim.ui.CLI.java
public static Options prepareOptions() { // Para adicionar uma evento: // 1. Defina uma constante com a identificao da opo // 2. Cria a Option referente // 3. Opcionalmente defina o tipo do argumento, quantidade de parmetros // ou restries // 4. Adicione a Options Options options = new Options(); Option availability = new Option(AVAILABILITY, "availability", true, "Arquivo com a caracterizao da disponibilidade para todos os recursos."); Option dedicatedResources = new Option(DEDICATED_RESOURCES, "dedicated", false, "Indica que os recursos so todos dedicados."); Option syntAvail = new Option(SYNTHETIC_AVAILABILITY, "synthetic_availability", true, "Disponibilidade dos recursos deve ser gerada sinteticamente."); Option syntAvailDur = new Option(SYNTHETIC_AVAILABILITY_DURATION, "synthetic_availability_duration", true, "At que momento gerar eventos de disponibilidade dos recursos."); Option workload = new Option(WORKLOAD, "workload", true, "Arquivo com o workload no format GWA (Grid Workload Archive)."); Option utilization = new Option(UTILIZATION, "utilization", true, "Arquivo em que ser registrada a utilizao da grade."); Option workerEvents = new Option(WORKER_EVENTS, "worker_events", true, "Arquivo em que sero registrados os eventos de disponibilidade."); Option taskEvents = new Option(TASK_EVENTS, "task_events", true, "Arquivo em que ser registrados os eventos de envolvendo tasks."); Option workloadType = new Option(WORKLOAD_TYPE, "workload_type", true, "The type of workload to read the workload file."); Option machinesDescription = new Option(MACHINES_DESCRIPTION, "machinesdescription", true, "Descrio das mquinas presentes em cada peer."); Option speedOption = new Option(NODE_MIPS_RATING, "speed", true, "A velocidade de cada mquina."); Option scheduler = new Option(SCHEDULER, "scheduler", true, "Indica qual scheduler dever ser usado."); Option peersDescription = new Option(PEERS_DESCRIPTION, "peers_description", true, "Arquivo descrevendo os peers."); Option numResByPeer = new Option(NUM_RESOURCES_BY_PEER, "nresources", true, "O nmero de rplicas para cada task."); Option numPeers = new Option(NUM_PEERS, "npeers", true, "O nmero de peers do grid."); Option nofOption = new Option(NOF, "nof", false, "Utiliza a Rede de Favores (NoF)."); Option erwOption = new Option(EXTRACT_REMOTE_WORKLOAD, "extract_remote_workload", true, "Extrai, para cada job, o subconjunto das tasks que rodaram em recursos remotos."); Option output = new Option(OUTPUT, "output", true, "O nome do arquivo em que o output da simulao ser gravado."); Option halt = new Option(HALT_SIMULATION, "halt", true, "O tempo em que a simulao deve parar incondicionalmente."); workload.setRequired(true);/* w w w. j av a 2 s .c om*/ peersDescription.setRequired(true); output.setRequired(true); workload.setType(File.class); peersDescription.setType(File.class); machinesDescription.setType(File.class); availability.setType(File.class); utilization.setType(File.class); workerEvents.setType(File.class); taskEvents.setType(File.class); output.setType(File.class); erwOption.setType(File.class); numResByPeer.setType(Number.class); numPeers.setType(Number.class); speedOption.setType(Number.class); // syntAvail.setType(Number.class); syntAvailDur.setType(Number.class); syntAvail.setType(String.class); halt.setType(Number.class); scheduler.setArgs(2); availability.setArgs(2); // syntAvail.setArgs(2); OptionGroup availGroup = new OptionGroup(); availGroup.addOption(availability); availGroup.addOption(dedicatedResources); availGroup.addOption(syntAvail); options.addOptionGroup(availGroup); options.addOption(workload); options.addOption(workloadType); options.addOption(machinesDescription); options.addOption(scheduler); options.addOption(syntAvailDur); options.addOption(output); options.addOption(erwOption); options.addOption(numResByPeer); options.addOption(numPeers); options.addOption(peersDescription); options.addOption(speedOption); options.addOption(nofOption); options.addOption(utilization); options.addOption(workerEvents); options.addOption(taskEvents); options.addOption(halt); options.addOption(VERBOSE, "verbose", false, "Informa todos os eventos importantes."); options.addOption(HELP, false, "Comando de ajuda."); options.addOption(USAGE, false, "Instrues de uso."); return options; }
From source file:com.trsst.Command.java
@SuppressWarnings("static-access") private void buildOptions(String[] argv, PrintStream out, InputStream in) { // NOTE: OptionsBuilder is NOT thread-safe // which was causing us random failures. Option o; portOptions = new Options(); o = new Option(null, "Specify port"); o.setRequired(false);//from w w w . j av a 2 s . c o m o.setArgs(1); o.setLongOpt("port"); portOptions.addOption(o); o = new Option(null, "Expose client API"); o.setRequired(false); o.setArgs(0); o.setLongOpt("api"); portOptions.addOption(o); o = new Option(null, "Launch embedded GUI"); o.setRequired(false); o.setArgs(0); o.setLongOpt("gui"); portOptions.addOption(o); o = new Option(null, "Turn off SSL"); o.setRequired(false); o.setArgs(0); o.setLongOpt("clear"); portOptions.addOption(o); o = new Option(null, "Use TOR (experimental)"); o.setRequired(false); o.setArgs(0); o.setLongOpt("tor"); portOptions.addOption(o); pullOptions = new Options(); o = new Option("h", "Set host server for this operation"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("host"); pullOptions.addOption(o); o = new Option("d", "Decrypt entries as specified recipient id"); o.setRequired(false); o.setArgs(1); o.setArgName("id"); o.setLongOpt("decrypt"); pullOptions.addOption(o); postOptions = new Options(); o = new Option("a", "Attach the specified file, or - for std input"); o.setRequired(false); o.setOptionalArg(true); o.setArgName("file"); o.setLongOpt("attach"); postOptions.addOption(o); o = new Option("b", "Set base URL for this feed"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("base"); postOptions.addOption(o); o = new Option("p", "Specify passphrase on the command line"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("pass"); postOptions.addOption(o); o = new Option("s", "Specify status update on command line"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("status"); postOptions.addOption(o); o = new Option("u", "Attach the specified url to the new entry"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("url"); postOptions.addOption(o); o = new Option("v", "Specify an activitystreams verb for this entry"); o.setRequired(false); o.setArgs(1); o.setArgName("verb"); o.setLongOpt("verb"); postOptions.addOption(o); o = new Option("r", "Add a mention"); o.setRequired(false); o.setArgs(1); o.setArgName("id"); o.setLongOpt("mention"); postOptions.addOption(o); o = new Option("g", "Add a tag"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("tag"); postOptions.addOption(o); o = new Option("c", "Specify entry content on command line"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("content"); postOptions.addOption(o); o = new Option("t", "Set this feed's title"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("title"); postOptions.addOption(o); o = new Option(null, "Set this feed's subtitle"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("subtitle"); postOptions.addOption(o); o = new Option("n", "Set this feed's author name"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("name"); postOptions.addOption(o); o = new Option(null, "Set this feed's author uri"); o.setRequired(false); o.setArgs(1); o.setArgName("uri"); o.setLongOpt("uri"); postOptions.addOption(o); o = new Option("e", "Encrypt entry for specified public key"); o.setRequired(false); o.setArgs(1); o.setArgName("pubkey"); o.setLongOpt("encrypt"); postOptions.addOption(o); o = new Option("m", "Set this feed's author email"); o.setRequired(false); o.setArgs(1); o.setArgName("email"); o.setLongOpt("email"); postOptions.addOption(o); o = new Option("i", "Set as this feed's icon or specify url"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("icon"); postOptions.addOption(o); o = new Option("l", "Set as this feed's logo or specify url"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("logo"); postOptions.addOption(o); o = new Option(null, "Generate feed id with specified prefix"); o.setRequired(false); o.setArgs(1); o.setArgName("prefix"); o.setLongOpt("vanity"); postOptions.addOption(o); o = new Option(null, "Require SSL certs"); o.setRequired(false); o.setArgs(0); o.setLongOpt("strict"); postOptions.addOption(o); // merge options parameters mergedOptions = new Options(); for (Object obj : pullOptions.getOptions()) { mergedOptions.addOption((Option) obj); } for (Object obj : postOptions.getOptions()) { mergedOptions.addOption((Option) obj); } for (Object obj : portOptions.getOptions()) { mergedOptions.addOption((Option) obj); } helpOption = OptionBuilder.isRequired(false).withLongOpt("help").withDescription("Display these options") .create('?'); mergedOptions.addOption(helpOption); }
From source file:io.janusproject.Boot.java
/** Replies the command line options supported by this boot class. * * @return the command line options./*from w ww . j a va 2 s . c o m*/ */ public static Options getOptions() { Option opt; Options options = new Options(); options.addOption("B", "bootid", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_B", //$NON-NLS-1$ JanusConfig.BOOT_DEFAULT_CONTEXT_ID_NAME, JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_NAME)); options.addOption("f", "file", true, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_F")); //$NON-NLS-1$ options.addOption("h", "help", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_H")); //$NON-NLS-1$ options.addOption("nologo", false, //$NON-NLS-1$ Locale.getString("CLI_HELP_NOLOGO")); //$NON-NLS-1$ options.addOption("o", "offline", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_O", JanusConfig.OFFLINE)); //$NON-NLS-1$ options.addOption("q", "quiet", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_Q")); //$NON-NLS-1$ options.addOption("R", "randomid", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_R", //$NON-NLS-1$ JanusConfig.BOOT_DEFAULT_CONTEXT_ID_NAME, JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_NAME)); options.addOption("s", "showdefaults", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_S")); //$NON-NLS-1$ options.addOption("v", "verbose", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_V")); //$NON-NLS-1$ options.addOption("W", "worldid", false, //$NON-NLS-1$//$NON-NLS-2$ Locale.getString("CLI_HELP_W", //$NON-NLS-1$ JanusConfig.BOOT_DEFAULT_CONTEXT_ID_NAME, JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_NAME)); StringBuilder b = new StringBuilder(); int l = 0; for (String logLevel : LoggerCreator.getLevelStrings()) { if (b.length() > 0) { b.append(", "); //$NON-NLS-1$ } b.append(logLevel); b.append(" ("); //$NON-NLS-1$ b.append(l); b.append(")"); //$NON-NLS-1$ ++l; } opt = new Option("l", "log", true, Locale.getString("CLI_HELP_L", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ JanusConfig.VERBOSE_LEVEL_VALUE, b)); opt.setArgs(1); options.addOption(opt); opt = new Option("D", true, Locale.getString("CLI_HELP_D")); //$NON-NLS-1$//$NON-NLS-2$ opt.setArgs(2); opt.setValueSeparator('='); opt.setArgName(Locale.getString("CLI_HELP_D_ARGNAME")); //$NON-NLS-1$ options.addOption(opt); return options; }
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); opt.setOptionalArg(true);//www . j a va 2 s .c om 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.rrze.idmone.utils.jpwgen.PwGenerator.java
/** * Initializes the CLI (Command Line Interface) options of the PwGenerator. * // w w w .ja va2s .c o m * @return the CLI options */ private synchronized static Options createOptions() { options = new Options(); Option option = createOption(CL_NUMBER_PASSWORD, CL_NUMBER_PASSWORD_LONG, CL_NUMBER_PASSWORD_DESC, true, false); options.addOption(option); option = createOption(CL_PASSWORD_LENGTH, CL_PASSWORD_LENGTH_LONG, CL_PASSWORD_LENGTH_DESC, true, false); options.addOption(option); option = createOption(CL_CAPITALIZE, CL_CAPITALIZE_LONG, CL_CAPITALIZE_DESC, false, false); options.addOption(option); option = createOption(CL_NO_CAPITALIZE, CL_NO_CAPITALIZE_LONG, CL_NO_CAPITALIZE_DESC, false, false); options.addOption(option); option = createOption(CL_NUMERALS, CL_NUMERALS_LONG, CL_NUMERALS_DESC, false, false); options.addOption(option); option = createOption(CL_NO_NUMERALS, CL_NO_NUMERALS_LONG, CL_NO_NUMERALS_DESC, false, false); options.addOption(option); option = createOption(CL_SYMBOLS, CL_SYMBOLS_LONG, CL_SYMBOLS_DESC, false, false); options.addOption(option); option = createOption(CL_SYMBOLS_REDUCED, CL_SYMBOLS_REDUCED_LONG, CL_SYMBOLS_REDUCED_DESC, false, false); options.addOption(option); option = createOption(CL_NO_SYMBOLS, CL_NO_SYMBOLS_LONG, CL_NO_SYMBOLS_DESC, false, false); options.addOption(option); option = createOption(CL_AMBIGOUS, CL_AMBIGOUS_LONG, CL_AMBIGOUS_DESC, false, false); options.addOption(option); option = createOption(CL_NO_AMBIGOUS, CL_NO_AMBIGOUS_LONG, CL_NO_AMBIGOUS_DESC, false, false); options.addOption(option); option = createOption(CL_HELP, CL_HELP_LONG, CL_HELP_DESC, false, false); options.addOption(option); option = createOption(CL_RANDOM, CL_RANDOM_LONG, CL_RANDOM_DESC, false, false); options.addOption(option); option = createOption(CL_COLUMN, CL_COLUMN_LONG, CL_COLUMN_DESC, false, false); options.addOption(option); option = createOption(CL_SR_PROVIDERS, CL_SR_PROVIDERS_LONG, CL_SR_PROVIDERS_DESC, false, false); options.addOption(option); option = createOption(CL_PROVIDERS, CL_PROVIDERS_LONG, CL_PROVIDERS_DESC, false, false); options.addOption(option); option = createOption(CL_SR_ALGORITHM, CL_SR_ALGORITHM_LONG, CL_SR_ALGORITHM_LONG, true, false); option.hasArgs(); option.setArgs(2); options.addOption(option); option = createOption(CL_TERM_WIDTH, CL_TERM_WIDTH_LONG, CL_TERM_WIDTH_DESC, true, false); options.addOption(option); option = createOption(CL_MAX_ATTEMPTS, CL_MAX_ATTEMPTS_LONG, CL_MAX_ATTEMPTS_DESC, true, false); options.addOption(option); // regex option = createOption(CL_REGEX_STARTS_NO_SMALL_LETTER, CL_REGEX_STARTS_NO_SMALL_LETTER_LONG, CL_REGEX_STARTS_NO_SMALL_LETTER_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ENDS_NO_SMALL_LETTER, CL_REGEX_ENDS_NO_SMALL_LETTER_LONG, CL_REGEX_ENDS_NO_SMALL_LETTER_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_STARTS_NO_UPPER_LETTER, CL_REGEX_STARTS_NO_UPPER_LETTER_LONG, CL_REGEX_STARTS_NO_UPPER_LETTER_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ENDS_NO_UPPER_LETTER, CL_REGEX_ENDS_NO_UPPER_LETTER_LONG, CL_REGEX_ENDS_NO_UPPER_LETTER_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ENDS_NO_DIGIT, CL_REGEX_ENDS_NO_DIGIT_LONG, CL_REGEX_ENDS_NO_DIGIT_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_STARTS_NO_DIGIT, CL_REGEX_STARTS_NO_DIGIT_LONG, CL_REGEX_STARTS_NO_DIGIT_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_STARTS_NO_SYMBOL, CL_REGEX_STARTS_NO_SYMBOL_LONG, CL_REGEX_STARTS_NO_SYMBOL_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ENDS_NO_SYMBOL, CL_REGEX_ENDS_NO_SYMBOL_LONG, CL_REGEX_ENDS_NO_SYMBOL_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ONLY_1_CAPITAL, CL_REGEX_ONLY_1_CAPITAL_LONG, CL_REGEX_ONLY_1_CAPITAL_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ONLY_1_SYMBOL, CL_REGEX_ONLY_1_SYMBOL_LONG, CL_REGEX_ONLY_1_SYMBOL_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_AT_LEAST_2_SYMBOLS, CL_REGEX_AT_LEAST_2_SYMBOLS_LONG, CL_REGEX_AT_LEAST_2_SYMBOLS_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_ONLY_1_DIGIT, CL_REGEX_ONLY_1_DIGIT_LONG, CL_REGEX_ONLY_1_DIGIT_DESC, false, false); options.addOption(option); option = createOption(CL_REGEX_AT_LEAST_2_DIGITS, CL_REGEX_AT_LEAST_2_DIGITS_LONG, CL_REGEX_AT_LEAST_2_DIGITS_DESC, false, false); options.addOption(option); return options; }
From source file:org.akvo.flow.InstanceConfigurator.java
private static Options getOptions() { Options options = new Options(); Option orgName = new Option("on", "Organzation name"); orgName.setLongOpt("orgName"); orgName.setArgs(1); orgName.setRequired(true);/*from w ww . j a v a2s . c o m*/ Option awsId = new Option("ak", "AWS Access Key"); awsId.setLongOpt("awsKey"); awsId.setArgs(1); awsId.setRequired(true); Option awsSecret = new Option("as", "AWS Access Secret"); awsSecret.setLongOpt("awsSecret"); awsSecret.setArgs(1); awsSecret.setRequired(true); Option bucketName = new Option("bn", "AWS S3 bucket name"); bucketName.setLongOpt("bucketName"); bucketName.setArgs(1); bucketName.setRequired(true); Option gaeServer = new Option("gae", "GAE instance id - The `x` in https://x.appspot.com"); gaeServer.setLongOpt("gaeId"); gaeServer.setArgs(1); gaeServer.setRequired(true); Option emailFrom = new Option("ef", "Sender email - NOTE: Must be developer in GAE instance"); emailFrom.setLongOpt("emailFrom"); emailFrom.setArgs(1); emailFrom.setRequired(false); Option emailTo = new Option("et", "Recipient email of error notifications"); emailTo.setLongOpt("emailTo"); emailTo.setArgs(1); emailTo.setRequired(true); Option flowServices = new Option("fs", "FLOW Services url, e.g. http://services.akvoflow.org"); flowServices.setLongOpt("flowServices"); flowServices.setArgs(1); flowServices.setRequired(true); Option outputFolder = new Option("o", "Output folder for configuration files"); outputFolder.setLongOpt("outFolder"); outputFolder.setArgs(1); outputFolder.setRequired(true); Option alias = new Option("a", "Instance alias, e.g. instance.akvoflow.org"); alias.setLongOpt("alias"); alias.setArgs(1); alias.setRequired(true); Option signingKey = new Option("sk", "Signing Key"); signingKey.setLongOpt("signingKey"); signingKey.setArgs(1); signingKey.setRequired(true); options.addOption(orgName); options.addOption(awsId); options.addOption(awsSecret); options.addOption(bucketName); options.addOption(gaeServer); options.addOption(emailFrom); options.addOption(emailTo); options.addOption(outputFolder); options.addOption(flowServices); options.addOption(alias); options.addOption(signingKey); return options; }
From source file:org.apache.accumulo.server.util.VerifyTabletAssignments.java
public static void main(String[] args) throws Exception { Options opts = new Options(); Option zooKeeperInstance = new Option("z", "zooKeeperInstance", true, "use a zookeeper instance with the given instance name and list of zoo hosts"); zooKeeperInstance.setArgName("name hosts"); zooKeeperInstance.setArgs(2); opts.addOption(zooKeeperInstance);// w w w . j a v a2 s .c om Option usernameOption = new Option("u", "user", true, "username (required)"); usernameOption.setArgName("user"); usernameOption.setRequired(true); opts.addOption(usernameOption); Option passwOption = new Option("p", "password", true, "password (prompt for password if this option is missing)"); passwOption.setArgName("pass"); opts.addOption(passwOption); Option verboseOption = new Option("v", "verbose", false, "verbose mode (prints locations of tablets)"); opts.addOption(verboseOption); CommandLine cl = null; String user = null; String passw = null; Instance instance = null; ConsoleReader reader = new ConsoleReader(); try { cl = new BasicParser().parse(opts, args); if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2) throw new MissingArgumentException(zooKeeperInstance); user = cl.getOptionValue(usernameOption.getOpt()); passw = cl.getOptionValue(passwOption.getOpt()); if (cl.hasOption(zooKeeperInstance.getOpt())) { String[] zkOpts = cl.getOptionValues(zooKeeperInstance.getOpt()); instance = new ZooKeeperInstance(zkOpts[0], zkOpts[1]); } else { instance = HdfsZooInstance.getInstance(); } if (passw == null) passw = reader.readLine( "Enter current password for '" + user + "'@'" + instance.getInstanceName() + "': ", '*'); if (passw == null) { reader.printNewline(); return; } // user canceled if (cl.getArgs().length != 0) throw new ParseException("Unrecognized arguments: " + cl.getArgList()); } catch (ParseException e) { PrintWriter pw = new PrintWriter(System.err); new HelpFormatter().printHelp(pw, Integer.MAX_VALUE, "accumulo " + VerifyTabletAssignments.class.getName(), null, opts, 2, 5, null, true); pw.flush(); System.exit(1); } Connector conn = instance.getConnector(user, passw.getBytes()); for (String table : conn.tableOperations().list()) checkTable(user, passw, table, null, cl.hasOption(verboseOption.getOpt())); }
From source file:org.apache.activemq.apollo.util.cli.OptionBuilder.java
public Option op() { Option option = new Option(id != null ? id : " ", description); option.setLongOpt(name);//from ww w. ja va2 s. c o m option.setRequired(required); option.setOptionalArg(optional); option.setType(type); option.setValueSeparator(sperator); if (arg != null && args == -1) { args = 1; } option.setArgs(args); option.setArgName(arg); return option; }
From source file:org.apache.blur.shell.ExecutePlatformCommandCommand.java
private void addOptions(boolean required, Options options, Set<Entry<String, ArgumentDescriptor>> entrySet) { for (Entry<String, ArgumentDescriptor> e : entrySet) { String argumentName = e.getKey(); ArgumentDescriptor argumentDescriptor = e.getValue(); Option option = OptionBuilder.create(argumentName); option.setRequired(required);//from ww w . j a va 2s. c om String description = argumentDescriptor.getDescription(); option.setDescription(createDescription(description, required)); option.setArgs(1); options.addOption(option); } }