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 */
017
018package org.apache.commons.cli;
019
020/**
021 * A class that implements the <code>CommandLineParser</code> interface
022 * can parse a String array according to the {@link Options} specified
023 * and return a {@link CommandLine}.
024 *
025 * @version $Id: CommandLineParser.java 1443102 2013-02-06 18:12:16Z tn $
026 */
027public interface CommandLineParser
028{
029    /**
030     * Parse the arguments according to the specified options.
031     *
032     * @param options the specified Options
033     * @param arguments the command line arguments
034     * @return the list of atomic option and value tokens
035     *
036     * @throws ParseException if there are any problems encountered
037     * while parsing the command line tokens.
038     */
039    CommandLine parse(Options options, String[] arguments) throws ParseException;
040
041    /**
042     * Parse the arguments according to the specified options and
043     * properties.
044     *
045     * @param options the specified Options
046     * @param arguments the command line arguments
047     * @param properties command line option name-value pairs
048     * @return the list of atomic option and value tokens
049     *
050     * @throws ParseException if there are any problems encountered
051     * while parsing the command line tokens.
052     */
053    /* To maintain binary compatibility, this is commented out.
054       It is still in the abstract Parser class, so most users will
055       still reap the benefit.
056    CommandLine parse(Options options, String[] arguments, Properties properties)
057               throws ParseException;
058     */
059
060    /**
061     * Parse the arguments according to the specified options.
062     *
063     * @param options the specified Options
064     * @param arguments the command line arguments
065     * @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops
066     *     the parsing and the remaining arguments are added to the 
067     *     {@link CommandLine}s args list. If <tt>false</tt> an unrecognized
068     *     argument triggers a ParseException.
069     *
070     * @return the list of atomic option and value tokens
071     * @throws ParseException if there are any problems encountered
072     * while parsing the command line tokens.
073     */
074    CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException;
075
076    /**
077     * Parse the arguments according to the specified options and
078     * properties.
079     *
080     * @param options the specified Options
081     * @param arguments the command line arguments
082     * @param properties command line option name-value pairs
083     * @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops
084     *     the parsing and the remaining arguments are added to the 
085     *     {@link CommandLine}s args list. If <tt>false</tt> an unrecognized
086     *     argument triggers a ParseException.
087     *
088     * @return the list of atomic option and value tokens
089     * @throws ParseException if there are any problems encountered
090     * while parsing the command line tokens.
091     */
092    /* To maintain binary compatibility, this is commented out.
093       It is still in the abstract Parser class, so most users will
094       still reap the benefit.
095    CommandLine parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
096            throws ParseException;
097     */
098}