Skip to content

Commit 89f6471

Browse files
committed
2 parents e30f005 + 523954d commit 89f6471

12 files changed

Lines changed: 100 additions & 57 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Checkout repository
48-
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
48+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
4949
with:
5050
persist-credentials: false
5151
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
@@ -57,7 +57,7 @@ jobs:
5757
5858
# Initializes the CodeQL tools for scanning.
5959
- name: Initialize CodeQL
60-
uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # 3.25.6
60+
uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # 3.25.10
6161
with:
6262
languages: ${{ matrix.language }}
6363
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -68,7 +68,7 @@ jobs:
6868
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6969
# If this step fails, then you should remove it and run the build manually (see below)
7070
- name: Autobuild
71-
uses: github/codeql-action/autobuild@9fdb3e49720b44c48891d036bb502feb25684276 # 3.25.6
71+
uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # 3.25.10
7272

7373
# ℹ️ Command-line programs to run using the OS shell.
7474
# 📚 https://git.io/JvXDl
@@ -82,4 +82,4 @@ jobs:
8282
# make release
8383

8484
- name: Perform CodeQL Analysis
85-
uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # 3.25.6
85+
uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # 3.25.10

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
java: [ 8 ]
3030

3131
steps:
32-
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
32+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
3333
with:
3434
persist-credentials: false
3535
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
@@ -47,6 +47,6 @@ jobs:
4747
run: mvn --show-version --batch-mode --no-transfer-progress test jacoco:report
4848

4949
- name: Upload coverage to Codecov
50-
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1
50+
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
5151
with:
5252
files: ./target/site/jacoco/jacoco.xml

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
experimental: true
3535

3636
steps:
37-
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
37+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
3838
with:
3939
persist-credentials: false
4040
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2

.github/workflows/scorecards-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
steps:
4141

4242
- name: "Checkout code"
43-
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
43+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
4444
with:
4545
persist-credentials: false
4646

@@ -64,6 +64,6 @@ jobs:
6464
retention-days: 5
6565

6666
- name: "Upload to code-scanning"
67-
uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # 3.25.6
67+
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # 3.25.10
6868
with:
6969
sarif_file: results.sarif

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
<parent>
2020
<groupId>org.apache.commons</groupId>
2121
<artifactId>commons-parent</artifactId>
22-
<version>70</version>
22+
<version>71</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525
<groupId>commons-cli</groupId>
2626
<artifactId>commons-cli</artifactId>
27-
<version>1.8.1-SNAPSHOT</version>
27+
<version>1.9.0-SNAPSHOT</version>
2828
<name>Apache Commons CLI</name>
2929
<inceptionYear>2002</inceptionYear>
3030
<description>
@@ -70,12 +70,12 @@
7070
<maven.compiler.target>1.8</maven.compiler.target>
7171
<commons.componentid>cli</commons.componentid>
7272
<commons.module.name>org.apache.commons.cli</commons.module.name>
73-
<commons.release.version>1.8.0</commons.release.version>
74-
<commons.release.next>1.8.1</commons.release.next>
73+
<commons.release.version>1.9.0</commons.release.version>
74+
<commons.release.next>1.9.1</commons.release.next>
7575
<commons.release.name>commons-cli-${commons.release.version}</commons.release.name>
7676
<commons.release.isDistModule>true</commons.release.isDistModule>
7777
<commons.rc.version>RC2</commons.rc.version>
78-
<commons.bc.version>1.7.0</commons.bc.version>
78+
<commons.bc.version>1.8.0</commons.bc.version>
7979
<commons.osgi.symbolicName>org.apache.commons.cli</commons.osgi.symbolicName>
8080
<commons.jira.id>CLI</commons.jira.id>
8181
<commons.jira.pid>12310463</commons.jira.pid>

src/changes/changes.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
<title>Apache Commons CLI Release Notes</title>
2323
</properties>
2424
<body>
25-
<release version="1.8.1" date="YYYY-MM-DD" description="This release contains new features and bug fixes and requires Java 8 or above.">
26-
<action type="add" issue="CLI-334" dev="ggregory" due-to="Eric Pugh">Fix Javadoc pathing #280.</action>
25+
<release version="1.9.0" date="YYYY-MM-DD" description="This release contains new features and bug fixes and requires Java 8 or above.">
26+
<!-- ADD -->
27+
<action type="add" dev="ggregory" due-to="Gary Gregory">Add OptionGroup.isSelected().</action>
28+
<!-- FIX -->
29+
<action type="fix" issue="CLI-334" dev="ggregory" due-to="Eric Pugh">Fix Javadoc pathing #280.</action>
30+
<action type="fix" issue="CLI-335" dev="ggregory" due-to="Claude Warren">Updated properties documentation #285 .</action>
31+
<!-- UPDATE -->
32+
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 70 to 71 #283.</action>
2733
</release>
2834
<release version="1.8.0" date="2024-05-18" description="This release contains new features and bug fixes and requires Java 8 or above.">
2935
<!-- ADD -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ private void handleProperties(final Properties properties) throws ParseException
443443
}
444444
// if the option is part of a group, check if another option of the group has been selected
445445
final OptionGroup group = options.getOptionGroup(opt);
446-
final boolean selected = group != null && group.getSelected() != null;
446+
final boolean selected = group != null && group.isSelected();
447447
if (!cmd.hasOption(option) && !selected) {
448448
// get the value from the properties
449449
final String value = properties.getProperty(option);

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class OptionGroup implements Serializable {
4141
private boolean required;
4242

4343
/**
44-
* Add the specified {@code Option} to this group.
44+
* Adds the given {@code Option} to this group.
4545
*
4646
* @param option the option to add to this group
4747
* @return this option group with the option added
@@ -54,23 +54,29 @@ public OptionGroup addOption(final Option option) {
5454
}
5555

5656
/**
57-
* @return the names of the options in this group as a {@code Collection}
57+
* Gets the names of the options in this group as a {@code Collection}.
58+
*
59+
* @return the names of the options in this group as a {@code Collection}.
5860
*/
5961
public Collection<String> getNames() {
6062
// the key set is the collection of names
6163
return optionMap.keySet();
6264
}
6365

6466
/**
65-
* @return the options in this group as a {@code Collection}
67+
* Gets the options in this group as a {@code Collection}.
68+
*
69+
* @return the options in this group as a {@code Collection}.
6670
*/
6771
public Collection<Option> getOptions() {
6872
// the values are the collection of options
6973
return optionMap.values();
7074
}
7175

7276
/**
73-
* @return the selected option name
77+
* Gets the selected option name.
78+
*
79+
* @return the selected option name.
7480
*/
7581
public String getSelected() {
7682
return selected;
@@ -86,7 +92,19 @@ public boolean isRequired() {
8692
}
8793

8894
/**
89-
* @param required specifies if this group is required
95+
* Tests whether an option is selected.
96+
*
97+
* @return whether whether an option is selected.
98+
* @since 1.9.0
99+
*/
100+
public boolean isSelected() {
101+
return selected != null;
102+
}
103+
104+
/**
105+
* Sets whether this group is required.
106+
*
107+
* @param required whether this group is required.
90108
*/
91109
public void setRequired(final boolean required) {
92110
this.required = required;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ protected void processProperties(final Properties properties) throws ParseExcept
273273
}
274274
// if the option is part of a group, check if another option of the group has been selected
275275
final OptionGroup group = options.getOptionGroup(opt);
276-
final boolean selected = group != null && group.getSelected() != null;
276+
final boolean selected = group != null && group.isSelected();
277277
if (!cmd.hasOption(option) && !selected) {
278278
// get the value from the properties instance
279279
final String value = properties.getProperty(option);

src/site/xdoc/properties.xml

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<a href="javadocs/api-release/org/apache/commons/cli/Option.html">Option</a> has. All of these
3232
can be set using the accessors or using the methods
3333
defined in the
34-
<a href="javadocs/api-release/org/apache/commons/cli/OptionBuilder.html">OptionBuilder</a>.
34+
<a href="javadocs/api-release/org/apache/commons/cli/Option.Builder.html">Option.Builder</a>.
3535
</p>
3636
<table>
3737
<tr>
@@ -40,68 +40,80 @@
4040
<th>Description</th>
4141
</tr>
4242
<tr>
43-
<td>opt</td>
44-
<td>java.lang.String</td>
45-
<td>the identification string of the Option.</td>
43+
<td>arg</td>
44+
<td>boolean</td>
45+
<td>A flag to say whether the option takes an argument.</td>
4646
</tr>
4747
<tr>
48-
<td>longOpt</td>
49-
<td>java.lang.String</td>
50-
<td>an alias and more descriptive identification string</td>
48+
<td>args</td>
49+
<td>boolean</td>
50+
<td>A flag to say whether the option takes more than one argument.</td>
5151
</tr>
5252
<tr>
53-
<td>description</td>
53+
<td>argName</td>
5454
<td>java.lang.String</td>
55-
<td>a description of the function of the option</td>
55+
<td>The name of the argument value for the usage statement.</td>
5656
</tr>
5757
<tr>
58-
<td>required</td>
59-
<td>boolean</td>
60-
<td>a flag to say whether the option <b>must</b> appear on
61-
the command line.</td>
58+
<td>converter</td>
59+
<td>org.apache.commons.cli.Converter&lt;T, E extends Throwable&gt;</td>
60+
<td>A FunctionalInterface that converts a String to type T and may throw an exception E. When
61+
CommandLine.getParsedValue() is called this FunctionalInterface will perform the conversion from the
62+
command line argument to the parsed type. This is used when a desired type is not registered, or to
63+
provide a custom type implementation. The 'type' property is not required to use the 'converter' property.</td>
6264
</tr>
6365
<tr>
64-
<td>arg</td>
65-
<td>boolean</td>
66-
<td>a flag to say whether the option takes an argument</td>
66+
<td>deprecated</td>
67+
<td>org.apache.commons.cli.DeprecatedAttributes</td>
68+
<td>Marks the option as deprecated and has the deprecation properties.</td>
6769
</tr>
6870
<tr>
69-
<td>args</td>
70-
<td>boolean</td>
71-
<td>a flag to say whether the option takes more than one argument</td>
71+
<td>description</td>
72+
<td>java.lang.String</td>
73+
<td>A description of the function of the option.</td>
7274
</tr>
7375
<tr>
74-
<td>optionalArg</td>
75-
<td>boolean</td>
76-
<td>a flag to say whether the option's argument is optional</td>
76+
<td>longOpt</td>
77+
<td>java.lang.String</td>
78+
<td>An alias and more descriptive identification string. May be null or not specified if 'opt' is provided.</td>
7779
</tr>
7880
<tr>
79-
<td>argName</td>
81+
<td>opt</td>
8082
<td>java.lang.String</td>
81-
<td>the name of the argument value for the usage statement</td>
83+
<td>The identification string of the Option. May be null or not specified if 'longOpt' is provided.</td>
8284
</tr>
8385
<tr>
84-
<td>valueSeparator</td>
85-
<td>char</td>
86-
<td>the character value used to split the argument string, that
87-
is used in conjunction with multipleArgs e.g.
88-
if the separator is ',' and the argument string is 'a,b,c' then
89-
there are three argument values, 'a', 'b' and 'c'.</td>
86+
<td>optionalArg</td>
87+
<td>boolean</td>
88+
<td>A flag to say whether the option's argument is optional.</td>
89+
</tr>
90+
<tr>
91+
<td>required</td>
92+
<td>boolean</td>
93+
<td>A flag to say whether the option <b>must</b> appear on the command line.</td>
9094
</tr>
9195
<tr>
9296
<td>type</td>
93-
<td>java.lang.Object</td>
94-
<td>the type of the argument</td>
97+
<td>java.lang.Class&lt;?&gt;</td>
98+
<td>The class of the object returned from getParsedValue(). The class must be registered in TypeHandler instance.
99+
See also 'converter' property.</td>
95100
</tr>
96101
<tr>
97102
<td>value</td>
98103
<td>java.lang.String</td>
99-
<td>the value of the option</td>
104+
<td>The value of the option.</td>
100105
</tr>
101106
<tr>
102107
<td>values</td>
103108
<td>java.lang.String[]</td>
104-
<td>the values of the option</td>
109+
<td>The values of the option.</td>
110+
</tr>
111+
<tr>
112+
<td>valueSeparator</td>
113+
<td>char</td>
114+
<td>The character value used to split the argument string, that is used in conjunction with multipleArgs e.g.
115+
if the separator is ',' and the argument string is 'a,b,c' then there are three argument values, 'a', 'b'
116+
and 'c'.</td>
105117
</tr>
106118
</table>
107119
</section>

0 commit comments

Comments
 (0)