Examples of Option


Examples of org.apache.commons.cli.Option

  {

    public DeleteUserCommand()
    {
      super("delete", "d");
      getOptions().addOption(new Option("u", "username", true, "name of user to delete"));
    }
View Full Code Here

Examples of org.apache.commons.cli.Option

    public ModifyUserCommand()
    {
      super("modify", "m");
     
      getOptions().addOption(new Option("u", "username", true, "name of user to modify"));
      getOptions().addOption(new Option("p", "password", true, "password for new user"));
      getOptions().addOption(new Option("t", "type", true, "user type (Admin / User / Guest)"));
      getOptions().addOption(new Option("d", "savedirectory", true, "default torrent save directory for this user"));

    }
View Full Code Here

Examples of org.apache.commons.cli2.Option

    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();
   
    Option helpOpt = DefaultOptionCreator.helpOption();
   
    Option inputDirOpt = obuilder.withLongName("input").withRequired(true).withArgument(
      abuilder.withName("input").withMinimum(1).withMaximum(1).create()).withDescription(
      "The input directory, containing properly formatted files: "
          + "One doc per line, first entry on the line is the label, rest is the evidence")
        .withShortName("i").create();
   
    Option outputOpt = obuilder.withLongName("output").withRequired(true).withArgument(
      abuilder.withName("output").withMinimum(1).withMaximum(1).create()).withDescription(
      "The output directory").withShortName("o").create();
   
   
    Group group = gbuilder.withName("Options").withOption(helpOpt).withOption(
View Full Code Here

Examples of org.apache.ecs.html.Option

    {
        Select monthSelect = new Select().setName(name);

        for (int curMonth = 0; curMonth <= 11; curMonth++)
        {
            Option o = new Option();
            o.addElement(monthName[curMonth]);
            o.setValue(curMonth);
            if ((now.get(Calendar.MONTH)) == curMonth)
            {
                o.setSelected(true);
            }
            monthSelect.addElement(o);
        }
        return (monthSelect);
    }
View Full Code Here

Examples of org.apache.ecs.xhtml.option

                {
                    previouslySelected = i;
                }
            }
           
            optionElements[i] = new option( options[i] );
            optionElements[i].addElement( options[i] );
        }

        if( previouslySelected > -1 ) optionElements[previouslySelected].setSelected(true);
        select field = new select( HANDLERPARAM_PREFIX + inputName, optionElements );
View Full Code Here

Examples of org.apache.felix.gogo.commands.Option

        Map<Argument, Field> arguments = new HashMap<Argument, Field>();
        List<Argument> orderedArguments = new ArrayList<Argument>();
        // Introspect
        for (Class type = action.getClass(); type != null; type = type.getSuperclass()) {
            for (Field field : type.getDeclaredFields()) {
                Option option = field.getAnnotation(Option.class);
                if (option != null) {
                    options.put(option, field);
                }
                Argument argument = field.getAnnotation(Argument.class);
                if (argument != null) {
                    if (Argument.DEFAULT.equals(argument.name())) {
                        final Argument delegate = argument;
                        final String name = field.getName();
                        argument = new Argument() {
                            public String name() {
                                return name;
                            }
                            public String description() {
                                return delegate.description();
                            }
                            public boolean required() {
                                return delegate.required();
                            }
                            public int index() {
                                return delegate.index();
                            }
                            public boolean multiValued() {
                                return delegate.multiValued();
                            }
                            public Class<? extends Annotation> annotationType() {
                                return delegate.annotationType();
                            }
                        };
                    }
                    arguments.put(argument, field);
                    int index = argument.index();
                    while (orderedArguments.size() <= index) {
                        orderedArguments.add(null);
                    }
                    if (orderedArguments.get(index) != null) {
                        throw new IllegalArgumentException("Duplicate argument index: " + index);
                    }
                    orderedArguments.set(index, argument);
                }
            }
        }
        // Check indexes are correct
        for (int i = 0; i < orderedArguments.size(); i++) {
            if (orderedArguments.get(i) == null) {
                throw new IllegalArgumentException("Missing argument for index: " + i);
            }
        }
        // Populate
        Map<Option, Object> optionValues = new HashMap<Option, Object>();
        Map<Argument, Object> argumentValues = new HashMap<Argument, Object>();
        boolean processOptions = true;
        int argIndex = 0;
        for (Iterator<Object> it = params.iterator(); it.hasNext();) {
            Object param = it.next();
            // Check for help
            if (HELP.name().equals(param) || Arrays.asList(HELP.aliases()).contains(param)) {
                printUsage(session, action, options, arguments, System.out);
                return false;
            }
            if (processOptions && param instanceof String && ((String) param).startsWith("-")) {
                boolean isKeyValuePair = ((String) param).indexOf('=') != -1;
                String name;
                Object value = null;
                if (isKeyValuePair) {
                    name = ((String) param).substring(0, ((String) param).indexOf('='));
                    value = ((String) param).substring(((String) param).indexOf('=') + 1);
                } else {
                    name = (String) param;
                }
                Option option = null;
                for (Option opt : options.keySet()) {
                    if (name.equals(opt.name()) || Arrays.asList(opt.aliases()).contains(name)) {
                        option = opt;
                        break;
                    }
                }
                if (option == null) {
                    Command command = action.getClass().getAnnotation(Command.class);
                    throw new CommandException(
                            Ansi.ansi()
                                    .fg(Ansi.Color.RED)
                                    .a("Error executing command ")
                                    .a(command.scope())
                                    .a(":")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(command.name())
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .a(" undefined option ")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(param)
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .fg(Ansi.Color.DEFAULT)
                                    .toString(),
                            "Undefined option: " + param
                    );
                }
                Field field = options.get(option);
                if (value == null && (field.getType() == boolean.class || field.getType() == Boolean.class)) {
                    value = Boolean.TRUE;
                }
                if (value == null && it.hasNext()) {
                    value = it.next();
                }
                if (value == null) {
                    Command command = action.getClass().getAnnotation(Command.class);
                    throw new CommandException(
                            Ansi.ansi()
                                    .fg(Ansi.Color.RED)
                                    .a("Error executing command ")
                                    .a(command.scope())
                                    .a(":")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(command.name())
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .a(" missing value for option ")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(param)
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .fg(Ansi.Color.DEFAULT)
                                    .toString(),
                            "Missing value for option: " + param
                    );
                }
                if (option.multiValued()) {
                    List<Object> l = (List<Object>) optionValues.get(option);
                    if (l == null) {
                        l = new ArrayList<Object>();
                        optionValues.put(option,  l);
                    }
                    l.add(value);
                } else {
                    optionValues.put(option, value);
                }
            } else {
                processOptions = false;
                if (argIndex >= orderedArguments.size()) {
                    Command command = action.getClass().getAnnotation(Command.class);
                    throw new CommandException(
                            Ansi.ansi()
                                    .fg(Ansi.Color.RED)
                                    .a("Error executing command ")
                                    .a(command.scope())
                                    .a(":")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(command.name())
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .a(": too many arguments specified")
                                    .fg(Ansi.Color.DEFAULT)
                                    .toString(),
                            "Too many arguments specified"
                    );
                }
                Argument argument = orderedArguments.get(argIndex);
                if (!argument.multiValued()) {
                    argIndex++;
                }
                if (argument.multiValued()) {
                    List<Object> l = (List<Object>) argumentValues.get(argument);
                    if (l == null) {
                        l = new ArrayList<Object>();
                        argumentValues.put(argument, l);
                    }
                    l.add(param);
                } else {
                    argumentValues.put(argument, param);
                }
            }
        }
        // Check required arguments / options
        for (Option option : options.keySet()) {
            if (option.required() && optionValues.get(option) == null) {
                Command command = action.getClass().getAnnotation(Command.class);
                throw new CommandException(
                        Ansi.ansi()
                                .fg(Ansi.Color.RED)
                                .a("Error executing command ")
                                .a(command.scope())
                                .a(":")
                                .a(Ansi.Attribute.INTENSITY_BOLD)
                                .a(command.name())
                                .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                .a(": option ")
                                .a(Ansi.Attribute.INTENSITY_BOLD)
                                .a(option.name())
                                .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                .a(" is required")
                                .fg(Ansi.Color.DEFAULT)
                                .toString(),
                        "Option " + option.name() + " is required"
                );
            }
        }
        for (Argument argument : arguments.keySet()) {
            if (argument.required() && argumentValues.get(argument) == null) {
View Full Code Here

Examples of org.apache.felix.gogo.options.Option

        "Usage: runTests [OPTION]... [TESTS]...",
        "  -? --help                show help",
        "  -d --directory=DIR       Write test results to specified directory",
        "  -q --quiet               Do not output test results to console"};
       
        Option opts = Options.compile( usage ).parse( args );
       
        boolean quiet = opts.isSet( "quiet" );
        Object d = opts.isSet( "directory" ) ? opts.getObject( "directory" ) : null;
        File dir = null;
        if (d != null)
        {
            if ( d instanceof File ) {
                dir = ( File ) d;
            }
            else {
                dir = new File(d.toString());               
            }
            dir.mkdirs();
            if (!quiet) {
                System.out.println("Writing results to " + dir.getAbsolutePath());
                System.out.flush();
            }
        }
       
        List<Object> tests = opts.argObjects();
       
        return runTests(tests, quiet, dir);
    }
View Full Code Here

Examples of org.apache.geronimo.jee.loginconfig.Option

  if (realmType.equals("Properties File Realm")) {
      loginModule
        .setLoginModuleClass("org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");

      String usersfile = page1.textEntries[0].getText().trim();
      Option usersfileopt = createOption("usersURI", usersfile);

      String groupsfile = page1.textEntries[1].getText().trim();
      Option groupsfileopt = createOption("groupsURI", groupsfile);

      String algorithm = page1.textEntries[2].getText();
      Option algorithmopt = createOption("digest", algorithm);

      String encoding = page1.textEntries[3].getText();
      Option encodingopt = createOption("encoding", encoding);

      loginModule.getOption().add(usersfileopt);
      loginModule.getOption().add(groupsfileopt);
      if (algorithm != null)
    loginModule.getOption().add(algorithmopt);
      if (encoding != null)
    loginModule.getOption().add(encodingopt);

  } else if (realmType.equals("SQL Realm")) {
      loginModule
        .setLoginModuleClass("org.apache.geronimo.security.realm.providers.SQLLoginModule");

      String selectUsers = page2.textEntries[0].getText().trim();
      Option selectUsersopt = createOption("userSelect", selectUsers);

      String selectGroups = page2.textEntries[1].getText().trim();
      Option selectGroupsopt = createOption("groupSelect", selectGroups);

      String algorithm = page2.textEntries[2].getText().trim();
      Option algorithmopt = createOption("digest", algorithm);

      String encoding = page2.textEntries[3].getText().trim();
      Option encodingopt = createOption("encoding", encoding);

      if (page3.buttons[0].getSelection()) {
    String dsname = page3.dataBasePoolCombo.getText();
    Option dsnameopt = createOption("dataSourceName", dsname);
    loginModule.getOption().add(dsnameopt);
      } else if (page3.buttons[1].getSelection()) {

    String jdbcDriverClass = page3.textEntries[0].getText().trim();
    Option jdbcDriverClassopt = createOption("jdbcDriver",
      jdbcDriverClass);

    String jdbcURL = page3.textEntries[1].getText().trim();
    Option jdbcURLopt = createOption("jdbcURL", jdbcURL);

    String userName = page3.textEntries[2].getText().trim();
    Option userNameopt = createOption("jdbcUser", userName);

    String password = page3.textEntries[3].getText().trim();
    Option passwordopt = createOption("jdbcPassword", password);

    loginModule.getOption().add(jdbcDriverClassopt);
    loginModule.getOption().add(jdbcURLopt);
    loginModule.getOption().add(userNameopt);
    loginModule.getOption().add(passwordopt);
View Full Code Here

Examples of org.apache.hadoop.io.SequenceFile.Reader.Option

    }
 
    @Override
    protected boolean doProcess(Record inputRecord, InputStream in) throws IOException {
      FSDataInputStream fsInputStream = new FSDataInputStream(new ForwardOnlySeekable(in));
      Option opt = SequenceFile.Reader.stream(fsInputStream);
      SequenceFile.Metadata sequenceFileMetaData = null;
      SequenceFile.Reader reader = null;
      try {
        reader = new SequenceFile.Reader(conf, opt);  
        if (includeMetaData) {
View Full Code Here

Examples of org.apache.jackrabbit.standalone.cli.Option

        }

        // Options
        iter = desc.getOptions().values().iterator();
        while (iter.hasNext()) {
            Option arg = (Option) iter.next();
            out.print("-" + arg.getName() + " <" + arg.getLocalizedArgName()
                    + "> ");
        }

        // flags
        iter = desc.getFlags().values().iterator();
        while (iter.hasNext()) {
            Flag arg = (Flag) iter.next();
            out.print("-" + arg.getName() + " ");
        }
        out.println();

        // Alias
        if (desc.getAlias().size() > 0) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.