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 https://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} interface can parse a String array according to the 022 * {@link Options} specified and return a {@link CommandLine}. 023 */ 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 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 033 */ 034 CommandLine parse(Options options, String[] arguments) throws ParseException; 035 036 /** 037 * Parses the arguments according to the specified options. 038 * 039 * @param options the specified Options. 040 * @param arguments the command line arguments. 041 * @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the remaining arguments 042 * are added to the {@link CommandLine}s args list. If {@code false} an unrecognized argument triggers a 043 * ParseException. 044 * 045 * @return the list of atomic option and value tokens. 046 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 047 */ 048 CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException; 049 050}