You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/10/17 15:18:54 UTC
(commons-cli) branch master updated (49b14971 -> eb0182ca)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
from 49b14971 DefaultParser.Builder implements Supplier<DefaultParser>
new af7abb35 Deprecate CommandLine.Builder() in favor of CommandLine.builder()
new eb0182ca Deprecate CommandLine.Builder() in favor of CommandLine.builder()
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 1 +
.../java/org/apache/commons/cli/CommandLine.java | 10 +++++++++
.../org/apache/commons/cli/CommandLineTest.java | 26 +++++++++++++---------
3 files changed, 27 insertions(+), 10 deletions(-)
(commons-cli) 02/02: Deprecate CommandLine.Builder() in favor of CommandLine.builder()
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit eb0182ca0428fcc3f26b55dae88f219b91491572
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 17 11:18:49 2024 -0400
Deprecate CommandLine.Builder() in favor of CommandLine.builder()
(commons-cli) 01/02: Deprecate CommandLine.Builder() in favor of CommandLine.builder()
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit af7abb3586c401e32fead7e17182f024afaf85a8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 17 11:18:49 2024 -0400
Deprecate CommandLine.Builder() in favor of CommandLine.builder()
---
src/changes/changes.xml | 1 +
.../java/org/apache/commons/cli/CommandLine.java | 10 +++++++++
.../org/apache/commons/cli/CommandLineTest.java | 26 +++++++++++++---------
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0a9cc72b..ed94b575 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,7 @@
<body>
<release version="1.9.1" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
<!-- FIX -->
+ <action type="add" issue="CLI-339" dev="ggregory" due-to="Gary Gregory">Deprecate CommandLine.Builder() in favor of CommandLine.builder().</action>
<!-- ADD -->
<action type="add" issue="CLI-339" dev="ggregory" due-to="Claude Warren, Gary Gregory">Help formatter extension in the new package #314.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">CommandLine.Builder implements Supplier<CommandLine>.</action>
diff --git a/src/main/java/org/apache/commons/cli/CommandLine.java b/src/main/java/org/apache/commons/cli/CommandLine.java
index 761061c7..246ad228 100644
--- a/src/main/java/org/apache/commons/cli/CommandLine.java
+++ b/src/main/java/org/apache/commons/cli/CommandLine.java
@@ -62,6 +62,16 @@ public class CommandLine implements Serializable {
*/
private Consumer<Option> deprecatedHandler = DEPRECATED_HANDLER;
+ /**
+ * Constructs a new instance.
+ *
+ * @deprecated Use {@link #build()}.
+ */
+ @Deprecated
+ public Builder() {
+ // empty
+ }
+
/**
* Adds left-over unrecognized option/argument.
*
diff --git a/src/test/java/org/apache/commons/cli/CommandLineTest.java b/src/test/java/org/apache/commons/cli/CommandLineTest.java
index 27f87baa..67a1bb6e 100644
--- a/src/test/java/org/apache/commons/cli/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/cli/CommandLineTest.java
@@ -219,10 +219,13 @@ public class CommandLineTest {
@Test
public void testBuilderBuild() {
- final CommandLine.Builder builder = new CommandLine.Builder();
- builder.addArg("foo").addArg("bar");
- builder.addOption(Option.builder("T").build());
- final CommandLine cmd = builder.build();
+ // @formatter:off
+ final CommandLine cmd = CommandLine.builder()
+ .addArg("foo")
+ .addArg("bar")
+ .addOption(Option.builder("T").build())
+ .build();
+ // @formatter:on
assertEquals("foo", cmd.getArgs()[0]);
assertEquals("bar", cmd.getArgList().get(1));
assertEquals("T", cmd.getOptions()[0].getOpt());
@@ -230,10 +233,13 @@ public class CommandLineTest {
@Test
public void testBuilderGet() {
- final CommandLine.Builder builder = new CommandLine.Builder();
- builder.addArg("foo").addArg("bar");
- builder.addOption(Option.builder("T").build());
- final CommandLine cmd = builder.get();
+ // @formatter:off
+ final CommandLine cmd = CommandLine.builder()
+ .addArg("foo")
+ .addArg("bar")
+ .addOption(Option.builder("T").build())
+ .get();
+ // @formatter:on
assertEquals("foo", cmd.getArgs()[0]);
assertEquals("bar", cmd.getArgList().get(1));
assertEquals("T", cmd.getOptions()[0].getOpt());
@@ -241,7 +247,7 @@ public class CommandLineTest {
@Test
public void testBuilderNullArgs() {
- final CommandLine.Builder builder = new CommandLine.Builder();
+ final CommandLine.Builder builder = CommandLine.builder();
builder.addArg(null).addArg(null);
builder.addOption(Option.builder("T").build());
final CommandLine cmd = builder.build();
@@ -252,7 +258,7 @@ public class CommandLineTest {
@Test
public void testBuilderNullOption() {
- final CommandLine.Builder builder = new CommandLine.Builder();
+ final CommandLine.Builder builder = CommandLine.builder();
builder.addArg("foo").addArg("bar");
builder.addOption(null);
builder.addOption(null);