Skip to content

Commit bc5f93f

Browse files
committed
Improved the javadoc explaining the stopAtNonOption parameter
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@954846 13f79535-47bb-0310-9956-ffa450edef68
1 parent e7c2198 commit bc5f93f

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/java/org/apache/commons/cli/CommandLineParser.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ CommandLine parse(Options options, String[] arguments, Properties properties)
6363
*
6464
* @param options the specified Options
6565
* @param arguments the command line arguments
66-
* @param stopAtNonOption specifies whether to continue parsing the
67-
* arguments if a non option is encountered.
66+
* @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops
67+
* the parsing and the remaining arguments are added to the
68+
* {@link CommandLine}s args list. If <tt>false</tt> an unrecognized
69+
* argument triggers a ParseException.
6870
*
6971
* @return the list of atomic option and value tokens
7072
* @throws ParseException if there are any problems encountered
@@ -79,7 +81,10 @@ CommandLine parse(Options options, String[] arguments, Properties properties)
7981
* @param options the specified Options
8082
* @param arguments the command line arguments
8183
* @param properties command line option name-value pairs
82-
* @param stopAtNonOption specifies whether to continue parsing the
84+
* @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops
85+
* the parsing and the remaining arguments are added to the
86+
* {@link CommandLine}s args list. If <tt>false</tt> an unrecognized
87+
* argument triggers a ParseException.
8388
*
8489
* @return the list of atomic option and value tokens
8590
* @throws ParseException if there are any problems encountered

src/java/org/apache/commons/cli/DefaultParser.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ public class DefaultParser implements CommandLineParser
3232
{
3333
protected CommandLine cmd;
3434
protected Options options;
35+
36+
/**
37+
* Flag indicating how unrecognized tokens are handled. <tt>true</tt> to stop
38+
* the parsing and add the remaining tokens to the args list.
39+
* <tt>false</tt> to throw an exception.
40+
*/
3541
protected boolean stopAtNonOption;
36-
42+
3743
/** The token currently processed. */
3844
protected String currentToken;
3945

@@ -251,7 +257,7 @@ private void handleUnknownToken(String token) throws ParseException
251257
if (stopAtNonOption)
252258
{
253259
skipParsing = true;
254-
}
260+
}
255261
}
256262

257263
/**

src/java/org/apache/commons/cli/Parser.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ public CommandLine parse(Options options, String[] arguments, Properties propert
108108
*
109109
* @param options the <code>Options</code>
110110
* @param arguments the <code>arguments</code>
111-
* @param stopAtNonOption specifies whether to stop interpreting the
112-
* arguments when a non option has been encountered
113-
* and to add them to the CommandLines args list.
111+
* @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops
112+
* the parsing and the remaining arguments are added to the
113+
* {@link CommandLine}s args list. If <tt>false</tt> an unrecognized
114+
* argument triggers a ParseException.
114115
* @return the <code>CommandLine</code>
115116
* @throws ParseException if an error occurs when parsing the arguments.
116117
*/
@@ -126,8 +127,10 @@ public CommandLine parse(Options options, String[] arguments, boolean stopAtNonO
126127
* @param options the specified Options
127128
* @param arguments the command line arguments
128129
* @param properties command line option name-value pairs
129-
* @param stopAtNonOption stop parsing the arguments when the first
130-
* non option is encountered.
130+
* @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops
131+
* the parsing and the remaining arguments are added to the
132+
* {@link CommandLine}s args list. If <tt>false</tt> an unrecognized
133+
* argument triggers a ParseException.
131134
*
132135
* @return the list of atomic option and value tokens
133136
*

0 commit comments

Comments
 (0)