[ 
https://issues.apache.org/jira/browse/KAFKA-6971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16699904#comment-16699904
 ] 

ASF GitHub Bot commented on KAFKA-6971:
---------------------------------------

omkreddy closed pull request #5732: KAFKA-6971 Passing in help flag to 
kafka-console-producer should print arg options
URL: https://github.com/apache/kafka/pull/5732
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/scala/kafka/tools/ConsoleConsumer.scala 
b/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
index 365652a75b5..96e7c6136cf 100755
--- a/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
+++ b/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
@@ -190,6 +190,7 @@ object ConsoleConsumer extends Logging {
 
   class ConsumerConfig(args: Array[String]) {
     val parser = new OptionParser(false)
+    val help = parser.accepts("help", "Print all options and its descriptions")
     val topicIdOpt = parser.accepts("topic", "The topic id to consume on.")
       .withRequiredArg
       .describedAs("topic")
@@ -274,11 +275,12 @@ object ConsoleConsumer extends Logging {
       .describedAs("consumer group id")
       .ofType(classOf[String])
 
-    if (args.length == 0)
+    val options: OptionSet = tryParse(parser, args)
+
+    if (args.length == 0 || options.has(help))
       CommandLineUtils.printUsageAndDie(parser, "The console consumer is a 
tool that reads data from Kafka and outputs it to standard output.")
 
     var groupIdPassed = true
-    val options: OptionSet = tryParse(parser, args)
     val enableSystestEventsLogging = options.has(enableSystestEventsLoggingOpt)
 
     // topic must be specified.
diff --git a/core/src/main/scala/kafka/tools/ConsoleProducer.scala 
b/core/src/main/scala/kafka/tools/ConsoleProducer.scala
index 8d8c42d36cf..689d12a0127 100644
--- a/core/src/main/scala/kafka/tools/ConsoleProducer.scala
+++ b/core/src/main/scala/kafka/tools/ConsoleProducer.scala
@@ -111,6 +111,7 @@ object ConsoleProducer {
 
   class ProducerConfig(args: Array[String]) {
     val parser = new OptionParser(false)
+    val help = parser.accepts("help", "Print all options and its descriptions")
     val topicOpt = parser.accepts("topic", "REQUIRED: The topic id to produce 
messages to.")
       .withRequiredArg
       .describedAs("topic")
@@ -205,7 +206,7 @@ object ConsoleProducer {
       .ofType(classOf[String])
 
     val options = parser.parse(args : _*)
-    if (args.length == 0)
+    if (args.length == 0 || options.has(help))
       CommandLineUtils.printUsageAndDie(parser, "Read data from standard input 
and publish it to Kafka.")
     CommandLineUtils.checkRequiredArgs(parser, options, topicOpt, 
brokerListOpt)
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Passing in help flag to kafka-console-producer should print arg options
> -----------------------------------------------------------------------
>
>                 Key: KAFKA-6971
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6971
>             Project: Kafka
>          Issue Type: Improvement
>          Components: core, producer 
>    Affects Versions: 1.1.0
>            Reporter: Yeva Byzek
>            Priority: Minor
>              Labels: newbie
>
> {{kafka-console-consumer --help}} prints "help is not a recognized option" as 
> well as output of options
> {{kafka-console-producer --help}} prints "help is not a recognized option" 
> but no output of options
> Possible solutions:
> (a) Enhance {{kafka-console-producer}} to also print out all options when a 
> user passes in an unrecognized option
> (b) Enhance both {{kafka-console-producer}} and {{kafka-console-consumer}} to 
> legitimately accept the {{--help}} flag



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to