Add a command line option.

@param option The option to add.
@param <O> The base option type.
@return The argument argumentParser.
432565
public <O extends BaseOption> ArgumentParser add(O option) {
        if (option.getName() != null) {
            if (longNameOptions.containsKey(option.getName())) {
                throw new IllegalArgumentException("Option " + option.getName() + " already exists");
            }
            if (parent != null && parent.longNameOptions.containsKey(option.getName())) {
                throw new IllegalArgumentException("Option " + option.getName() + " already exists in parent");
            }

            longNameOptions.put(option.getName(), option);
        }

        if (option instanceof Flag) {
            String negate = ((Flag) option).getNegateName();
            if (negate != null) {
                if (longNameOptions.containsKey(negate)) {
                    throw new IllegalArgumentException("Flag " + negate + " already exists");
                }
                if (parent != null && parent.longNameOptions.containsKey(negate)) {
                    throw new IllegalArgumentException("Flag " + negate + " already exists in parent");
                }

                longNameOptions.put(negate, option);
            }
        }

        if (option.getShortNames()
                  .length() > 0) {
            for (char s : option.getShortNames()
                                .toCharArray()) {
                if (shortOptions.containsKey(s)) {
                    throw new IllegalArgumentException("Short option -" + s + " already exists");
                }
                if (parent != null && parent.shortOptions.containsKey(s)) {
                    throw new IllegalArgumentException("Short option -" + s + " already exists in parent");
                }

                shortOptions.put(s, option);
            }
        }

        this.options.add(option);
        return this;
    }
385524
def addOption(self, o):
    
    if self.hasOption(o.short):
      raise InterfaceException("Failed adding option - already have " + str(o))
    self.options.append(o)
782588
private void appendOption(StringBuilder sb, Option option, boolean required) {
        if (!required) {
            sb.append(OPTIONAL_BRACKET_OPEN);
        }
        if (option.getName() != null) {
            sb.append(OPTION_PREFIX).append(option.getName());
        } else {
            sb.append(LONG_OPTION_PREFIX).append(option.getLongName());
        }
        // if the Option has a value and a non blank arg name
        if (option.hasValue() && (option.getValueName() == null || !option.getValueName().isEmpty())) {
            sb.append(option.isWithEqualSign() ? '=' : LONG_OPTION_SEPARATOR);
            sb.append(ARG_BRACKET_OPEN).append(option.getValueName() != null ? option.getValueName() : getArgName()).append(ARG_BRACKET_CLOSE);
        }
        if (!required) {
            sb.append(OPTIONAL_BRACKET_CLOSE);
        }
    }
863743
private void _appendOption (@Nonnull final StringBuilder aSB, @Nonnull final Option aOption, final boolean bRequired)
  {
    if (!bRequired)
      aSB.append ('[');

    if (aOption.hasShortOpt ())
      aSB.append (getOptPrefix ()).append (aOption.getShortOpt ());
    else
      aSB.append (getLongOptPrefix ()).append (aOption.getLongOpt ());

    // if the Option has a value and a non blank argname
    if (aOption.canHaveArgs ())
    {
      aSB.append (aOption.hasShortOpt () ? " " : getLongOptSeparator ());
      aSB.append ('<').append (aOption.hasArgName () ? aOption.getArgName () : getArgName ()).append ('>');
    }

    // if the Option is not a required option
    if (!bRequired)
      aSB.append (']');
  }
201013
private static CommandLine parseCommandLine(Options options, String[] args) throws ParseException {
        CommandLineParser parser = new GroovyInternalPosixParser();
        return parser.parse(options, args, true);
    }
544541
public ConfigOptionBuilder setCommandLineOptionWithArgument( CommandLineOption commandLineOption, StringConverter converter ) {
        co.setCommandLineOption( commandLineOption );
        return setStringConverter( converter );
    }
1341178
public OptionsBuilder option(String option, Object value) {
        this.options.setOption(option, value);
        return this;
    }
1017674
public static MOAObject fromCommandLine(ClassOption option, String commandline) {
  	return fromCommandLine(option.getRequiredType(), commandline);
  }
1228510
public final <T> void addOption(Class<T> cls, String name, String description, String exclusiveGroup, boolean mandatory)
    {
        if (names.contains(name))
        {
            throw new IllegalArgumentException(name+" is already added as argument");
        }
        Option opt = new Option(cls, name, description, exclusiveGroup, mandatory);
        Option old = map.put(name, opt);
        if (old != null)
        {
            throw new IllegalArgumentException(name+" was already added");
        }
        if (exclusiveGroup != null)
        {
            groups.add(exclusiveGroup, opt);
        }
    }
630990
public CmdLineAction arg(String arg) {
		if (!CmdLineProcessor.isActionArg(arg)) {
			throw new IllegalArgumentException(arg);
		}
		this.args.add(arg);
		return this;
	}
1254153
public void addArgument(AstNode arg) {
        assertNotNull(arg);
        if (arguments == null) {
            arguments = new ArrayList<AstNode>();
        }
        arguments.add(arg);
        arg.setParent(this);
    }
144484
public final <T> void addArgument(Class<T> cls, String name)
    {
        if (map.containsKey(name))
        {
            throw new IllegalArgumentException(name+" is already added as option");
        }
        if (hasArrayArgument)
        {
            throw new IllegalArgumentException("no argument allowed after array argument");
        }
        types.add(cls);
        names.add(name);
        if (cls.isArray())
        {
            hasArrayArgument = true;
        }
    }
1123633
public void addSelectOption(CmsSelectWidgetOption option) {

        if (m_selectOptions == null) {
            m_selectOptions = new ArrayList<CmsSelectWidgetOption>();
        }
        m_selectOptions.add(option);
    }
1220625
protected void addCommandLineArgument(StringBuilder buffer,String argument,String value)
    {
        if((value!=null)&&(value.length()>0))
        {
            buffer.append(argument);
            buffer.append(Fax4jExeConstants.SPACE_STR);
            buffer.append(Fax4jExeConstants.VALUE_WRAPPER);
            buffer.append(value);
            buffer.append(Fax4jExeConstants.VALUE_WRAPPER);
            buffer.append(Fax4jExeConstants.SPACE_STR);
        }
    }
515024
private static PluginOption parsePluginOption(final Element option) {
        PluginOption po = new PluginOption();
        po.setArgName(option.attributeValue("argName"));
        po.setArgsCount(Integer.valueOf(option.attributeValue("argsCount", "1")));
        po.setArgsOptional(Boolean.valueOf(option.attributeValue("optionalArgs", "false")));
        po.setDescription(option.attributeValue("description"));
        po.setHasArgs(Boolean.parseBoolean(option.attributeValue("hasArgs", "false")));
        po.setLongOpt(option.attributeValue("longName"));
        po.setOption(option.attributeValue("shortName"));
        po.setRequired(Boolean.parseBoolean(option.attributeValue("required", "false")));
        po.setType(option.attributeValue("type"));
        po.setValueSeparator(option.attributeValue("separator"));

        return po;
    }
694416
public void addArg(FunctionLibFunctionArg arg) {
	arg.setFunction(this);
	argument.add(arg);
	if (arg.getDefaultValue() != null) hasDefaultValues = true;
    }
422215
private void addPrefixOption(String arg) {
    int i = arg.indexOf('=');
    if (i < 1) {
      usage("invalid prefix format");
    }
    packagePrefixes.addPrefix(arg.substring(0, i), arg.substring(i + 1));
  }