001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.cli2;
018
019import java.util.List;
020
021/**
022 * A CommandLine that detected values and options can be written to.
023 */
024public interface WriteableCommandLine extends CommandLine {
025
026    /**
027     * Adds an Option to the CommandLine
028     * @param option the Option to add
029     */
030    void addOption(final Option option);
031
032    /**
033     * Adds a value to an Option in the CommandLine.
034     * @param option the Option to add to
035     * @param value the value to add
036     */
037    void addValue(final Option option, final Object value);
038
039    /**
040     * Retrieves the Argument values specified on the command line for the
041     * specified Option, this doesn't return any values supplied
042     * programmatically as defaults.
043     *
044     * @param option the Option associated with the values
045     * @return a list of values or an empty List if none are found
046     */
047    List getUndefaultedValues(final Option option);
048
049    /**
050     * Sets the default values for an Option in the CommandLine
051     * @param option the Option to add to
052     * @param defaultValues the defaults for the option
053     */
054    void setDefaultValues(final Option option, final List defaultValues);
055
056    /**
057     * Adds a switch value to an Option in the CommandLine.
058     * @param option the Option to add to
059     * @param value the switch value to add
060     * @throws IllegalStateException if the switch has already been added
061     */
062    void addSwitch(final Option option, final boolean value) throws IllegalStateException;
063
064    /**
065     * Sets the default state for a Switch in the CommandLine.
066     * @param option the Option to add to
067     * @param defaultSwitch the defaults state for ths switch
068     */
069    void setDefaultSwitch(final Option option, final Boolean defaultSwitch);
070
071    /**
072     * Adds a property value to a name in the CommandLine.
073     * Replaces any existing value for the property.
074     *
075     * @param option the Option to add to
076     * @param property the name of the property
077     * @param value the value of the property
078     */
079    void addProperty(final Option option, final String property, final String value);
080
081    /**
082     * Adds a property value to the default property set.
083     * Replaces any existing value for the property.
084     *
085     * @param property the name of the property
086     * @param value the value of the property
087     */
088    void addProperty(final String property, final String value);
089
090    /**
091     * Detects whether the argument looks like an Option trigger
092     * @param argument the argument to test
093     * @return true if the argument looks like an Option trigger
094     */
095    boolean looksLikeOption(final String argument);
096
097    /**
098     * Returns the option that is currently processed.
099     *
100     * @return the current option
101     */
102    Option getCurrentOption();
103
104    /**
105     * Sets the current option. This method is called by concrete option
106     * implementations during command line processing. It enables the command
107     * line to keep track about the option that is currently processed.
108     *
109     * @param currentOption the new current option
110     */
111    void setCurrentOption(Option currentOption);
112}