Skip to content

Commit

Permalink
Propagate argument to 'reload' to load failure handling command. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Nov 24, 2013
1 parent 7f8c056 commit e268db3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions main/src/main/scala/sbt/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,19 @@ object BuiltinCommands

def project = Command.make(ProjectCommand, projectBrief, projectDetailed)(ProjectNavigation.command)

def loadFailed = Command.command(LoadFailed)(handleLoadFailed)
@tailrec def handleLoadFailed(s: State): State =
def loadFailed = Command(LoadFailed)(loadProjectParser)(doLoadFailed)

@deprecated("No longer used.", "0.13.2")
def handleLoadFailed(s: State): State = doLoadFailed(s, "")

@tailrec
private[this] def doLoadFailed(s: State, loadArg: String): State =
{
val result = (SimpleReader.readLine("Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? ") getOrElse Quit).toLowerCase(Locale.ENGLISH)
def matches(s: String) = !result.isEmpty && (s startsWith result)

if(result.isEmpty || matches("retry"))
LoadProject :: s.clearGlobalLog
loadProjectCommand(LoadProject, loadArg) :: s.clearGlobalLog
else if(matches(Quit))
s.exit(ok = false)
else if(matches("ignore"))
Expand All @@ -425,22 +430,24 @@ object BuiltinCommands
s
}
else if(matches("last"))
LastCommand :: LoadFailed :: s
LastCommand :: loadProjectCommand(LoadFailed, loadArg) :: s
else
{
println("Invalid response.")
handleLoadFailed(s)
doLoadFailed(s, loadArg)
}
}

def loadProjectCommands(arg: String) =
StashOnFailure ::
(OnFailure + " " + LoadFailed) ::
(LoadProjectImpl + " " + arg).trim ::
(OnFailure + " " + loadProjectCommand(LoadFailed, arg)) ::
loadProjectCommand(LoadProjectImpl, arg) ::
PopOnFailure ::
State.FailureWall ::
Nil
def loadProject = Command(LoadProject, LoadProjectBrief, LoadProjectDetailed)(_ => matched(Project.loadActionParser)) { (s,arg) => loadProjectCommands(arg) ::: s }
def loadProject = Command(LoadProject, LoadProjectBrief, LoadProjectDetailed)(loadProjectParser) { (s,arg) => loadProjectCommands(arg) ::: s }
private[this] def loadProjectParser = (s: State) => matched(Project.loadActionParser)
private[this] def loadProjectCommand(command: String, arg: String): String = s"$command $arg".trim

def loadProjectImpl = Command(LoadProjectImpl)(_ => Project.loadActionParser)( doLoadProject )
def doLoadProject(s0: State, action: LoadAction.Value): State =
Expand Down

0 comments on commit e268db3

Please sign in to comment.