Skip to content
Open
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 LICENSE-binary
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ see: licenses/CDDL+GPL-1.1
---------------------------------------
MIT License

- argparse4j-0.7.0, see: licenses/argparse-MIT
- argparse4j-0.9.0, see: licenses/argparse-MIT
- classgraph-4.8.179, see: licenses/classgraph-MIT
- jopt-simple-5.0.4, see: licenses/jopt-simple-MIT
- slf4j-api-1.7.36, see: licenses/slf4j-MIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void taskConfigs(SourceAndTarget sourceAndTarget, String connector, Callb
}

public static void main(String[] args) {
ArgumentParser parser = ArgumentParsers.newArgumentParser("connect-mirror-maker");
ArgumentParser parser = ArgumentParsers.newFor("connect-mirror-maker").build();
parser.description("MirrorMaker 2.0 driver");
parser.addArgument("config").type(Arguments.fileType().verifyCanRead())
.metavar("mm2.properties").required(true)
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/scala/kafka/docker/KafkaDockerWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ object KafkaDockerWrapper extends Logging {

private def parseArguments(args: Array[String]): Namespace = {
val parser = ArgumentParsers.
newArgumentParser("kafka-docker-wrapper", true, "-", "@").
newFor("kafka-docker-wrapper").
addHelp(true).
prefixChars("-").
fromFilePrefix("@").
build().
description("The Kafka docker wrapper.")

val subparsers = parser.addSubparsers().dest("command")
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala/kafka/tools/StorageTool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import kafka.utils.Logging
import net.sourceforge.argparse4j.ArgumentParsers
import net.sourceforge.argparse4j.impl.Arguments.{append, store, storeTrue}
import net.sourceforge.argparse4j.inf.{ArgumentParserException, Namespace, Subparser, Subparsers}
import net.sourceforge.argparse4j.internal.HelpScreenException
import net.sourceforge.argparse4j.helper.HelpScreenException
import org.apache.kafka.common.Uuid
import org.apache.kafka.common.utils.Utils
import org.apache.kafka.common.utils.internals.Exit
Expand Down Expand Up @@ -291,7 +291,11 @@ object StorageTool extends Logging {

def parseArguments(args: Array[String]): Namespace = {
val parser = ArgumentParsers
.newArgumentParser("kafka-storage", /* defaultHelp */true, /* prefixChars */"-", /* fromFilePrefix */ "@")
.newFor("kafka-storage")
.addHelp(true)
.prefixChars("-")
.fromFilePrefix("@")
.build()
.description("The Kafka storage tool.")

val subparsers = parser.addSubparsers().dest("command")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ static int sizeOfUnsignedVarint(int value) {

public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("message-generator")
.newFor("message-generator")
.build()
.defaultHelp(true)
.description("The Kafka message generator");
parser.addArgument("--package", "-p")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
package org.apache.kafka.message.checker;

import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;
import net.sourceforge.argparse4j.internal.HelpScreenException;

import java.io.PrintStream;

Expand All @@ -41,7 +41,8 @@ public static void run(
PrintStream writer
) throws Exception {
ArgumentParser argumentParser = ArgumentParsers.
newArgumentParser("metadata-schema-checker").
newFor("metadata-schema-checker").
build().
defaultHelp(true).
description("The Kafka metadata schema checker tool.");
Subparsers subparsers = argumentParser.addSubparsers().dest("command");
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ versions += [
activation: "1.1.1",
apacheda: "1.0.2",
apacheds: "2.0.0-M24",
argparse4j: "0.7.0",
argparse4j: "0.9.0",
bcpkix: "1.85",
caffeine: "3.2.0",
checkstyle: project.hasProperty('checkstyleVersion') ? checkstyleVersion : "12.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public void close() {

public static void main(String[] args) {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("kafka-metadata-shell")
.newFor("kafka-metadata-shell")
.build()
.defaultHelp(true)
.description("The Apache Kafka metadata shell");
parser.addArgument("--snapshot", "-s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import org.apache.kafka.shell.state.MetadataShellState;

import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;
import net.sourceforge.argparse4j.internal.HelpScreenException;

import org.jline.reader.Candidate;

Expand Down Expand Up @@ -104,7 +104,7 @@ void completeNext(
* @param addShellCommands True if we should include the shell-only commands.
*/
public Commands(boolean addShellCommands) {
this.parser = ArgumentParsers.newArgumentParser("", false);
this.parser = ArgumentParsers.newFor("").addHelp(false).build();
Subparsers subparsers = this.parser.addSubparsers().dest("command");
for (Type type : TYPES.values()) {
if (addShellCommands || !type.shellOnly()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void run(
writer.println("man: unknown command " + cmd +
". Type help to get a list of commands.");
} else {
ArgumentParser parser = ArgumentParsers.newArgumentParser(type.name(), false);
ArgumentParser parser = ArgumentParsers.newFor(type.name()).addHelp(false).build();
type.addArguments(parser);
writer.printf("%s: %s%n%n", cmd, type.description());
parser.printHelp(writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ static class TestConfig {

public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("client-compatibility-test")
.newFor("client-compatibility-test")
.build()
.defaultHelp(true)
.description("This tool is used to verify client compatibility guarantees.");
parser.addArgument("--topic")
Expand Down
3 changes: 2 additions & 1 deletion tools/src/main/java/org/apache/kafka/tools/ClusterTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ static int mainNoExit(String... args) {

static void execute(String... args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("kafka-cluster")
.newFor("kafka-cluster")
.build()
.defaultHelp(true)
.description("The Kafka cluster tool.");
Subparsers subparsers = parser.addSubparsers().dest("command");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static Map<String, String> parseWorkerProperties(ArgumentParser parser,
}

private static ArgumentParser parser() {
var parser = ArgumentParsers.newArgumentParser("connect-internal-topics")
var parser = ArgumentParsers.newFor("connect-internal-topics").build()
.defaultHelp(true)
.description("Manage internal topics required by Kafka Connect clusters (config, status, and offset topics).");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static int mainNoExit(String[] args, PrintStream out, PrintStream err) {
}

private static ArgumentParser parser() {
ArgumentParser parser = ArgumentParsers.newArgumentParser("connect-plugin-path")
ArgumentParser parser = ArgumentParsers.newFor("connect-plugin-path").build()
.defaultHelp(true)
.description("Manage plugins on the Connect plugin.path");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
import org.apache.kafka.server.util.CommandLineUtils;

import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.impl.Arguments;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;
import net.sourceforge.argparse4j.internal.HelpScreenException;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -74,7 +74,8 @@ static int mainNoExit(String... args) {

static void execute(String... args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("kafka-features")
.newFor("kafka-features")
.build()
.defaultHelp(true)
.description("This tool manages feature flags in Kafka.");
MutuallyExclusiveGroup bootstrapGroup = parser.addMutuallyExclusiveGroup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.kafka.server.util.Csv;

import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.impl.Arguments;
import net.sourceforge.argparse4j.inf.ArgumentGroup;
import net.sourceforge.argparse4j.inf.ArgumentParser;
Expand All @@ -44,7 +45,6 @@
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;
import net.sourceforge.argparse4j.internal.HelpScreenException;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -97,7 +97,8 @@ static int mainNoExit(String... args) {

static void execute(String... args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("kafka-metadata-quorum")
.newFor("kafka-metadata-quorum")
.build()
.defaultHelp(true)
.description("This tool describes kraft metadata quorum status.");
MutuallyExclusiveGroup connectionOptions = parser.addMutuallyExclusiveGroup().required(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ private static class ArgsHandler {

private ArgsHandler() {
this.parser = ArgumentParsers
.newArgumentParser("oauth-compatibility-tool")
.newFor("oauth-compatibility-tool")
.build()
.defaultHelp(true)
.description(DESCRIPTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class PrintVersionAndExitAction implements ArgumentAction {

@Override
@SuppressWarnings("deprecation") // Required by argparse4j until its legacy callback is removed.
public void run(
ArgumentParser parser,
Argument arg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ static List<byte[]> readPayloadFile(String payloadFilePath, String payloadDelimi
/** Get the command-line argument parser. */
static ArgumentParser argParser() {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("kafka-producer-perf-test")
.newFor("kafka-producer-perf-test")
.build()
.defaultHelp(true)
.description("This tool is used to verify the producer performance. To enable transactions, " +
"you can specify a transactional id or set a transaction duration using --transaction-duration-ms. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public class TransactionalMessageCopier {
/** Get the command-line argument parser. */
private static ArgumentParser argParser() {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("transactional-message-copier")
.newFor("transactional-message-copier")
.build()
.defaultHelp(true)
.description("This tool copies messages transactionally from an input partition to an output topic, " +
"committing the consumed offsets along with the output messages");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ private static Admin buildAdminClient(Namespace ns) {

static ArgumentParser buildBaseParser() {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("kafka-transactions.sh");
.newFor("kafka-transactions.sh").build();

parser.description("This tool is used to analyze the transactional state of producers in the cluster. " +
"It can be used to detect and recover from hanging transactions.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ public long maxOffset() {

private static ArgumentParser argParser() {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("verifiable-consumer")
.newFor("verifiable-consumer")
.build()
.defaultHelp(true)
.description("This tool consumes messages from a specific topic and emits consumer events (e.g. group rebalances, received messages, and offsets committed) as JSON objects to STDOUT.");
MutuallyExclusiveGroup connectionGroup = parser.addMutuallyExclusiveGroup("Connection Group")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public VerifiableProducer(KafkaProducer<String, String> producer, String topic,
/** Get the command-line argument parser. */
private static ArgumentParser argParser() {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("verifiable-producer")
.newFor("verifiable-producer")
.build()
.defaultHelp(true)
.description("This tool produces increasing integers to the specified topic and prints JSON metadata to stdout on each \"send\" request, making externally visible which messages have been acked and which have not.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ public String toString() {

private static ArgumentParser argParser() {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("verifiable-share-consumer")
.newFor("verifiable-share-consumer")
.build()
.defaultHelp(true)
.description("This tool creates a share group and consumes messages from a specific topic and emits share consumer events (e.g. share consumer startup, received messages, and offsets acknowledged) as JSON objects to STDOUT.");
MutuallyExclusiveGroup connectionGroup = parser.addMutuallyExclusiveGroup("Connection Group")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ boolean exec(TaskSpec spec, PrintStream out) throws Exception {

public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("trogdor-agent")
.newFor("trogdor-agent")
.build()
.defaultHelp(true)
.description("The Trogdor fault injection agent");
parser.addArgument("--agent.config", "-c")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ private static void addWorkerIdArgument(ArgumentParser parser, String help) {

public static void main(String[] args) throws Exception {
ArgumentParser rootParser = ArgumentParsers
.newArgumentParser("trogdor-agent-client")
.newFor("trogdor-agent-client")
.build()
.defaultHelp(true)
.description("The Trogdor agent client.");
Subparsers subParsers = rootParser.addSubparsers().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public void waitForShutdown() throws Exception {

public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers
.newArgumentParser("trogdor-coordinator")
.newFor("trogdor-coordinator")
.build()
.defaultHelp(true)
.description("The Trogdor fault injection coordinator");
parser.addArgument("--coordinator.config", "-c")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ private static void addJsonArgument(ArgumentParser parser) {

public static void main(String[] args) throws Exception {
ArgumentParser rootParser = ArgumentParsers
.newArgumentParser("trogdor-coordinator-client")
.newFor("trogdor-coordinator-client")
.build()
.description("The Trogdor coordinator client.");
Subparsers subParsers = rootParser.addSubparsers().
dest("command");
Expand Down