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 Apache.CLI;
018
019/**
020 * A class that implements the {@code CommandLineParser} interface can parse a String array
021 * according to the {@link Options} specified and return a {@link CommandLine}.
022 */
023@Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="LICENSE")
024public interface CommandLineParser
025{
026    /**
027     * Parses the arguments according to the specified options.
028     *
029     * @param options the specified Options
030     * @param arguments the command line arguments
031     * @return the list of atomic option and value tokens
032     *
033     * @throws ParseException if there are any problems encountered while parsing the command line tokens.
034     */
035    CommandLine parse(Options options, String[] arguments) throws ParseException;
036
037    /**
038     * Parses the arguments according to the specified options.
039     *
040     * @param options the specified Options
041     * @param arguments the command line arguments
042     * 
043     * @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the
044     * remaining arguments are added to the {@link CommandLine}s args list. If {@code false} an
045     * unrecognized argument triggers a ParseException.
046     *
047     * @return the list of atomic option and value tokens
048     * 
049     * @throws ParseException if there are any problems encountered while parsing the command line
050     * tokens.
051     */
052    CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
053        throws ParseException;
054}