Skip to content

Commit 639e070

Browse files
committed
[CLI-224] Add hasArgs and hasArg method to new Builder.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@1447088 13f79535-47bb-0310-9956-ffa450edef68
1 parent faa6455 commit 639e070

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/main/java/org/apache/commons/cli/Option.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,16 @@ public Builder valueSeparator(final char sep)
931931
return this;
932932
}
933933

934+
/**
935+
* Indicates that the Option will require an argument.
936+
*
937+
* @return this builder, to allow method chaining
938+
*/
939+
public Builder hasArg()
940+
{
941+
return hasArg(true);
942+
}
943+
934944
/**
935945
* Indicates if the Option has an argument or not.
936946
*
@@ -943,7 +953,18 @@ public Builder hasArg(final boolean hasArg)
943953
numberOfArgs = hasArg ? 1 : Option.UNINITIALIZED;
944954
return this;
945955
}
946-
956+
957+
/**
958+
* Indicates that the Option can have unlimited argument values.
959+
*
960+
* @return this builder, to allow method chaining
961+
*/
962+
public Builder hasArgs()
963+
{
964+
numberOfArgs = Option.UNLIMITED_VALUES;
965+
return this;
966+
}
967+
947968
/**
948969
* Constructs an Option with the values declared by this {@link Builder}.
949970
*

0 commit comments

Comments
 (0)