mirror of https://github.com/sbt/sbt.git
Merge pull request #8447 from Francluob/fix/8344-batch-mode-load-failed-prompt
[2.x] fix: Skips interactive prompt in batch mode when project loading
This commit is contained in:
commit
df90cb967c
|
|
@ -869,25 +869,30 @@ object BuiltinCommands {
|
||||||
|
|
||||||
@tailrec
|
@tailrec
|
||||||
private def doLoadFailed(s: State, loadArg: String): State = {
|
private def doLoadFailed(s: State, loadArg: String): State = {
|
||||||
s.log.warn("Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)")
|
// In batch mode, exit with failure to avoid infinite retry loops on persistent errors
|
||||||
val result: Int =
|
if (ITerminal.console.prompt == Prompt.Batch) {
|
||||||
try
|
s.exit(ok = false)
|
||||||
ITerminal.get.withRawInput(System.in.read) match {
|
} else {
|
||||||
case -1 => 'q'.toInt
|
s.log.warn("Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)")
|
||||||
case b => b
|
val result: Int =
|
||||||
}
|
try
|
||||||
catch { case _: ClosedChannelException => 'q' }
|
ITerminal.get.withRawInput(System.in.read) match {
|
||||||
def retry: State = loadProjectCommand(LoadProject, loadArg) :: s.clearGlobalLog
|
case -1 => 'q'.toInt
|
||||||
def ignoreMsg: String =
|
case b => b
|
||||||
if (Project.isProjectLoaded(s)) "using previously loaded project" else "no project loaded"
|
}
|
||||||
|
catch { case _: ClosedChannelException => 'q' }
|
||||||
|
def retry: State = loadProjectCommand(LoadProject, loadArg) :: s.clearGlobalLog
|
||||||
|
def ignoreMsg: String =
|
||||||
|
if (Project.isProjectLoaded(s)) "using previously loaded project" else "no project loaded"
|
||||||
|
|
||||||
result.toChar match {
|
result.toChar match {
|
||||||
case '\n' | '\r' => retry
|
case '\n' | '\r' => retry
|
||||||
case 'r' | 'R' => retry
|
case 'r' | 'R' => retry
|
||||||
case 'q' | 'Q' => s.exit(ok = false)
|
case 'q' | 'Q' => s.exit(ok = false)
|
||||||
case 'i' | 'I' => s.log.warn(s"Ignoring load failure: $ignoreMsg."); s
|
case 'i' | 'I' => s.log.warn(s"Ignoring load failure: $ignoreMsg."); s
|
||||||
case 'l' | 'L' => LastCommand :: loadProjectCommand(LoadFailed, loadArg) :: s
|
case 'l' | 'L' => LastCommand :: loadProjectCommand(LoadFailed, loadArg) :: s
|
||||||
case c => println(s"Invalid response: '$c'"); doLoadFailed(s, loadArg)
|
case c => println(s"Invalid response: '$c'"); doLoadFailed(s, loadArg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue