Fix client argument parsing for commands containing `-`

When the user ran a command like `testOnly foo -- bar`, the client was
incorrectly treating the `--` as an sbt argument. The assumption is that
once an argument is found that does not start with a `-`, then
everything following that argument is part of the command arguments.
This commit is contained in:
Ethan Atkins 2020-06-26 20:56:02 -07:00
parent aaee092c96
commit 3216848c77
1 changed files with 3 additions and 6 deletions

View File

@ -744,23 +744,20 @@ object NetworkClient {
case a if a.startsWith("\"") => Array(a)
case a => a.split(" ")
}
var foundCompletions = false
var i = 0
while (i < sanitized.length) {
sanitized(i) match {
case a if foundCompletions => completionArguments += a
case a if completionArguments.nonEmpty => completionArguments += a
case a if commandArgs.nonEmpty => commandArgs += a
case a if a == noStdErr || a == noTab || a.startsWith(completions) =>
foundCompletions = true
completionArguments += a
case a if a.startsWith("--sbt-script=") =>
sbtScript = a.split("--sbt-script=").lastOption.getOrElse(sbtScript)
case a if !a.startsWith("-") => commandArgs += a
case a if !a.startsWith("-") => commandArgs += a
case a @ SysProp(key, value) =>
System.setProperty(key, value)
sbtArguments += a
case a if !foundCompletions =>
sbtArguments += a
case a => sbtArguments += a
}
i += 1
}