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} 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 * 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 and properties. 039 * 040 * @param options the specified Options 041 * @param arguments the command line arguments 042 * @param properties command line option name-value pairs 043 * @return the list of atomic option and value tokens 044 * 045 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 046 */ 047 /* 048 * To maintain binary compatibility, this is commented out. It is still in the abstract Parser class, so most users will 049 * still reap the benefit. CommandLine parse(Options options, String[] arguments, Properties properties) throws 050 * ParseException; 051 */ 052 053 /** 054 * Parses the arguments according to the specified options. 055 * 056 * @param options the specified Options 057 * @param arguments the command line arguments 058 * @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the remaining arguments 059 * are added to the {@link CommandLine}s args list. If {@code false} an unrecognized argument triggers a 060 * ParseException. 061 * 062 * @return the list of atomic option and value tokens 063 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 064 */ 065 CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException; 066 067 /** 068 * Parses the arguments according to the specified options and properties. 069 * 070 * @param options the specified Options 071 * @param arguments the command line arguments 072 * @param properties command line option name-value pairs 073 * @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the remaining arguments 074 * are added to the {@link CommandLine}s args list. If {@code false} an unrecognized argument triggers a 075 * ParseException. 076 * 077 * @return the list of atomic option and value tokens 078 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 079 */ 080 /* 081 * To maintain binary compatibility, this is commented out. It is still in the abstract Parser class, so most users will 082 * still reap the benefit. CommandLine parse(Options options, String[] arguments, Properties properties, boolean 083 * stopAtNonOption) throws ParseException; 084 */ 085}