Use withRequiredArg while parsing jopt options in all tools; patched by Swapnil Ghike; reviewed by Jun Rao; kafka-786

This commit is contained in:
Swapnil Ghike 2013-03-06 09:21:56 -08:00 committed by Jun Rao
parent a971a27b59
commit 2e64c6a5f2
4 changed files with 5 additions and 19 deletions

View File

@ -30,17 +30,7 @@ object DumpLogSegments {
def main(args: Array[String]) {
val parser = new OptionParser
val printOpt = parser.accepts("print-data-log", "if set, printing the messages content when dumping data logs")
.withOptionalArg
.describedAs("print data log content")
.ofType(classOf[java.lang.Boolean])
.defaultsTo(false)
val verifyOpt = parser.accepts("verify-index-only", "if set, just verify the index log without printing its content")
.withOptionalArg
.describedAs("just verify the index log")
.ofType(classOf[java.lang.Boolean])
.defaultsTo(false)
val filesOpt = parser.accepts("files", "REQUIRED: The comma separated list of data and index log files to be dumped")
.withRequiredArg
.describedAs("file1, file2, ...")

View File

@ -43,7 +43,7 @@ object JmxTool extends Logging {
val attributesOpt =
parser.accepts("attributes", "The whitelist of attributes to query. This is a comma-separated list. If no " +
"attributes are specified all objects will be queried.")
.withOptionalArg()
.withRequiredArg
.describedAs("name")
.ofType(classOf[String])
val reportingIntervalOpt = parser.accepts("reporting-interval", "Interval in MS with which to poll jmx stats.")
@ -54,7 +54,7 @@ object JmxTool extends Logging {
val helpOpt = parser.accepts("help", "Print usage information.")
val dateFormatOpt = parser.accepts("date-format", "The date format to use for formatting the time field. " +
"See java.text.SimpleDateFormat for options.")
.withOptionalArg()
.withRequiredArg
.describedAs("format")
.ofType(classOf[String])
val jmxServiceUrlOpt =

View File

@ -54,12 +54,12 @@ object SimpleConsumerShell extends Logging {
.ofType(classOf[java.lang.Integer])
.defaultsTo(UseLeaderReplica)
val offsetOpt = parser.accepts("offset", "The offset id to consume from, default to -2 which means from beginning; while value -1 means from end")
.withOptionalArg()
.withRequiredArg
.describedAs("consume offset")
.ofType(classOf[java.lang.Long])
.defaultsTo(OffsetRequest.EarliestTime)
val clientIdOpt = parser.accepts("clientId", "The ID of this client.")
.withOptionalArg
.withRequiredArg
.describedAs("clientId")
.ofType(classOf[String])
.defaultsTo("SimpleConsumerShell")
@ -78,10 +78,6 @@ object SimpleConsumerShell extends Logging {
.describedAs("prop")
.ofType(classOf[String])
val printOffsetOpt = parser.accepts("print-offsets", "Print the offsets returned by the iterator")
.withOptionalArg
.describedAs("print offsets")
.ofType(classOf[java.lang.Boolean])
.defaultsTo(false)
val maxWaitMsOpt = parser.accepts("max-wait-ms", "The max amount of time each fetch request waits.")
.withRequiredArg
.describedAs("ms")

View File

@ -134,7 +134,7 @@ object SimpleConsumerPerformance {
.ofType(classOf[java.lang.Integer])
.defaultsTo(1024*1024)
val clientIdOpt = parser.accepts("clientId", "The ID of this client.")
.withOptionalArg
.withRequiredArg
.describedAs("clientId")
.ofType(classOf[String])
.defaultsTo("SimpleConsumerPerformanceClient")