in scala/src/main/org/apache/spark/launcher/SparkCLRSubmitArguments.scala [135:189]
protected def parse(args: List[String]): Unit = {
val eqSeparatedOpt = "(--[^=]+)=(.+)".r
def findCliOption(name: String, available: Array[Array[String]]): Option[Array[String]] = {
available.find(candidates => !candidates.find(_ == name).isEmpty)
}
var curIdx = -1
breakable {
args.zipWithIndex.foreach {
case (e, idx) if (idx <= curIdx) => // skip
case (e, idx) => {
curIdx = idx
var (arg, value) = e match {
case eqSeparatedOpt(arg, value) => (arg, value)
case _ => (e, null)
}
arg match {
case arg if !findCliOption(arg, options).isEmpty => {
val cliOption = findCliOption(arg, options).get.head
if (value == null) {
if (idx == args.length) {
throw new IllegalArgumentException("Missing argument for option '%s'." + arg)
}
curIdx = idx + 1
value = args(curIdx)
}
if (!handle(cliOption, value)) {
break
}
}
case arg if !findCliOption(arg, switches).isEmpty => {
val cliOption = findCliOption(arg, switches).get.head
if (!handle(cliOption, null)) {
break
}
}
case arg => {
if (!handleUnknown(arg)) {
break
}
}
}
}
}
}
handleExtraArgs(args.slice(curIdx + 1, args.length))
}