garydgregory commented on code in PR #382:
URL: https://github.com/apache/commons-cli/pull/382#discussion_r2254163961
##########
src/main/java/org/apache/commons/cli/Option.java:
##########
@@ -103,6 +103,9 @@ private static Class<?> toType(final Class<?> type) {
/** The character that is the value separator. */
private char valueSeparator;
+ /** multiple values are within a single argument separated by
valueSeparator char */
Review Comment:
A sentence should start with a capital letter.
##########
src/main/java/org/apache/commons/cli/Option.java:
##########
@@ -350,6 +359,51 @@ public Builder valueSeparator(final char valueSeparator) {
return this;
}
+ /**
+ * The Option will use ',' to invoke listValueSeparator()
+ *
+ * @since 1.11.0
+ * @return this builder.
+ */
+ public Builder listValueSeparator() {
+ return listValueSeparator(Char.COMMA);
+ }
+
+ /**
+ * defines the separator used to split a list of values passed in a
single argument.
Review Comment:
A sentence should start with a capital letter.
##########
src/main/java/org/apache/commons/cli/Option.java:
##########
@@ -350,6 +359,51 @@ public Builder valueSeparator(final char valueSeparator) {
return this;
}
+ /**
+ * The Option will use ',' to invoke listValueSeparator()
+ *
+ * @since 1.11.0
+ * @return this builder.
+ */
+ public Builder listValueSeparator() {
+ return listValueSeparator(Char.COMMA);
+ }
+
+ /**
+ * defines the separator used to split a list of values passed in a
single argument.
+ *
+ * Method is mutually exclusive to valueSeparator() method. In the
resulting option,
+ * isValueSeparatorUsedForSingleArgument() will return true.
+ *
+ * <p>
+ * <strong>Example:</strong>
+ * </p>
+ *
+ * <pre>
+ * final Option colors =
Option.builder().option("c").hasArgs().listValueSeparator('|').build();
+ * final Options options = new Options();
+ * options.addOption(colors);
+ *
+ * final String[] args = {"-c", "red|blue|yellow", "b,c"};
+ * final DefaultParser parser = new DefaultParser();
+ * final CommandLine commandLine = parser.parse(options, args, null,
true);
+ * final String [] colorValues = commandLine.getOptionValues(colors);
+ * // colorValues[0] will be "red"
+ * // colorValues[1] will be "blue"
+ * // colorValues[2] will be "yellow"
+ * final String arguments = commandLine.getArgs()[0]; // will be b,c
+ *
+ * </pre>
+ *
+ * @since 1.11.0
Review Comment:
The since tag should be after the param tags.
##########
src/main/java/org/apache/commons/cli/Option.java:
##########
@@ -834,6 +892,27 @@ public boolean isRequired() {
return required;
}
+ /**
+ * Tests whether multiple values are expected in a single argument split
by a separation character
+ *
+ * @return boolean true when the builder's listValueSeparator() method was
used. Multiple values are expected in a single argument and
+ * are split by a separation character.
+ * @since 1.10.0
+ */
+ public boolean isValueSeparatorUsedForSingleArgument() {
+ return valueSeparatorUsedForSingleArgument;
+ }
+
+ /**
+ * Set this to true to use the valueSeparator only on a single argument.
See also builder's listValueSeparator() method.
+ *
+ * @param valueSeparatorUsedForSingleArgument the new value for this
property
+ * @since 1.10.0
Review Comment:
Since tag is wrong.
##########
src/main/java/org/apache/commons/cli/Option.java:
##########
@@ -430,6 +484,9 @@ public static Builder builder(final String option) {
/** The character that is the value separator. */
private char valueSeparator;
+ /** multiple values are within a single argument separated by
valueSeparator char */
+ private boolean valueSeparatorUsedForSingleArgument;
Review Comment:
A sentence should start with a capital letter.
##########
src/main/java/org/apache/commons/cli/Option.java:
##########
@@ -834,6 +892,27 @@ public boolean isRequired() {
return required;
}
+ /**
+ * Tests whether multiple values are expected in a single argument split
by a separation character
+ *
+ * @return boolean true when the builder's listValueSeparator() method was
used. Multiple values are expected in a single argument and
+ * are split by a separation character.
+ * @since 1.10.0
Review Comment:
Since tag is wrong.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]