Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
<commons.surefire-report.version>3.0.0-M5</commons.surefire-report.version>
<commons.surefire.version>3.0.0-M5</commons.surefire.version>
<commons.felix.version>5.1.2</commons.felix.version>
<biz.aQute.bndlib.version>5.3.0</biz.aQute.bndlib.version>
<biz.aQute.bndlib.version>6.0.0</biz.aQute.bndlib.version>
<spotbugs.plugin.version>4.4.2.1</spotbugs.plugin.version>
<spotbugs.impl.version>4.4.2</spotbugs.impl.version>
<commons.animal-sniffer.version>1.20</commons.animal-sniffer.version>
Expand Down
5 changes: 4 additions & 1 deletion src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<action type="add" dev="ggregory" due-to="Alex Nordlund" issue="CLI-282">
TypeHandler should throw ParseException for an unsupported class.
</action>
<action type="add" dev="ggregory" due-to="waso, Gary Gregory">
Added setter for Builder.option #33.
</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" issue="CLI-294">
Update Java from version 5 to 7.
Expand Down Expand Up @@ -104,7 +107,7 @@
Bump maven-bundle-plugin 5.1.1 -> 5.1.2.
</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">
Bump biz.aQute.bndlib.version 5.1.2 -> 5.3.0.
Bump biz.aQute.bndlib.version 5.1.2 -> 6.0.0.
</action>
<action type="update" dev="ggregory" due-to="Dependabot">
Bump spotbugs from 4.4.1 to 4.4.2 #70.
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/org/apache/commons/cli/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class Option implements Cloneable, Serializable {
public static final class Builder {

/** The name of the option */
private final String option;
private String option;

/** description of the option */
private String description;
Expand Down Expand Up @@ -175,6 +175,19 @@ public Builder numberOfArgs(final int numberOfArgs) {
return this;
}

/**
* Sets the name of the Option.
*
* @param option the name of the Option
* @return this builder, to allow method chaining
* @throws IllegalArgumentException if there are any non valid Option characters in {@code opt}
* @since 1.5
*/
public Builder option(String option) throws IllegalArgumentException {
this.option = OptionValidator.validate(option);
return this;
}

/**
* Sets whether the Option can have an optional argument.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/cli/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
*/
@Deprecated
public abstract class Parser implements CommandLineParser {
/** commandline instance */
/** CommandLine instance */
protected CommandLine cmd;

/** current Options */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void setUp() {
}

@Test
public void testBuilder() throws Exception {
public void testBuilder() {
parser = DefaultParser.builder()
.setStripLeadingAndTrailingQuotes(false)
.setAllowPartialMatching(false)
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/apache/commons/cli/OptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public void testBuilderMethods() {
String.class);
checkOption(Option.builder("a").desc("desc").type(Integer.class).build(), "a", "desc", null, Option.UNINITIALIZED, null, false, false, defaultSeparator,
Integer.class);
checkOption(Option.builder().option("a").desc("desc").type(Integer.class).build(), "a", "desc", null, Option.UNINITIALIZED, null, false, false,
defaultSeparator, Integer.class);
}

@Test
Expand Down