lianetm commented on code in PR #18031:
URL: https://github.com/apache/kafka/pull/18031#discussion_r1869586621
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:
##########
@@ -130,6 +155,15 @@ else if (opts.options.has(opts.resetOffsetsOpt)) {
}
}
+ static void validateRegex(String regex) {
+ try {
+ Pattern.compile(regex);
+ System.out.printf("The regular expressions `%s` is valid.%n",
regex);
Review Comment:
```suggestion
System.out.printf("The regular expression `%s` is valid.%n",
regex);
```
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:
##########
@@ -210,7 +216,9 @@ private ConsumerGroupCommandOptions(String[] args) {
void checkArgs() {
CommandLineUtils.maybePrintHelpOrVersion(this, "This tool helps to
list all consumer groups, describe a consumer group, delete consumer group
info, or reset consumer group offsets.");
- CommandLineUtils.checkRequiredArgs(parser, options,
bootstrapServerOpt);
+ if (!options.has(validateRegexOpt)) {
+ CommandLineUtils.checkRequiredArgs(parser, options,
bootstrapServerOpt);
+ }
Review Comment:
agree, but should we then update the bootstrap doc that states it's required?
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:
##########
@@ -130,6 +155,15 @@ else if (opts.options.has(opts.resetOffsetsOpt)) {
}
}
+ static void validateRegex(String regex) {
+ try {
+ Pattern.compile(regex);
+ System.out.printf("The regular expressions `%s` is valid.%n",
regex);
+ } catch (PatternSyntaxException ex) {
+ System.out.printf("The regular expressions `%s` is invalid:
%s.%n", regex, ex.getDescription());
Review Comment:
```suggestion
System.out.printf("The regular expression `%s` is invalid:
%s.%n", regex, ex.getDescription());
```
--
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]