1 /* 2 Licensed to the Apache Software Foundation (ASF) under one or more 3 contributor license agreements. See the NOTICE file distributed with 4 this work for additional information regarding copyright ownership. 5 The ASF licenses this file to You under the Apache License, Version 2.0 6 (the "License"); you may not use this file except in compliance with 7 the License. You may obtain a copy of the License at 8 9 https://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 */ 17 18 package org.apache.commons.cli; 19 20 /** 21 * A class that implements the {@code CommandLineParser} interface can parse a String array according to the 22 * {@link Options} specified and return a {@link CommandLine}. 23 */ 24 public interface CommandLineParser { 25 26 /** 27 * Parses the arguments according to the specified options. 28 * 29 * @param options the specified Options 30 * @param arguments the command line arguments 31 * @return the list of atomic option and value tokens 32 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 33 */ 34 CommandLine parse(Options options, String[] arguments) throws ParseException; 35 36 /** 37 * Parses the arguments according to the specified options and properties. 38 * 39 * @param options the specified Options 40 * @param arguments the command line arguments 41 * @param properties command line option name-value pairs 42 * @return the list of atomic option and value tokens 43 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 44 */ 45 /* 46 * To maintain binary compatibility, this is commented out. It is still in the abstract Parser class, so most users will 47 * still reap the benefit. CommandLine parse(Options options, String[] arguments, Properties properties) throws 48 * ParseException; 49 */ 50 51 /** 52 * Parses the arguments according to the specified options. 53 * 54 * @param options the specified Options 55 * @param arguments the command line arguments 56 * @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the remaining arguments 57 * are added to the {@link CommandLine}s args list. If {@code false} an unrecognized argument triggers a 58 * ParseException. 59 * 60 * @return the list of atomic option and value tokens 61 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 62 */ 63 CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException; 64 65 /** 66 * Parses the arguments according to the specified options and properties. 67 * 68 * @param options the specified Options 69 * @param arguments the command line arguments 70 * @param properties command line option name-value pairs 71 * @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the remaining arguments 72 * are added to the {@link CommandLine}s args list. If {@code false} an unrecognized argument triggers a 73 * ParseException. 74 * 75 * @return the list of atomic option and value tokens 76 * @throws ParseException if there are any problems encountered while parsing the command line tokens. 77 */ 78 /* 79 * To maintain binary compatibility, this is commented out. It is still in the abstract Parser class, so most users will 80 * still reap the benefit. CommandLine parse(Options options, String[] arguments, Properties properties, boolean 81 * stopAtNonOption) throws ParseException; 82 */ 83 }