Exec and CommandExchange refactoring

This commit is contained in:
Eugene Yokota
2016-10-27 02:42:12 -04:00
parent 3359163636
commit a89fcb37ca
5 changed files with 74 additions and 52 deletions
@@ -6,7 +6,7 @@ import sbt.internal.util.complete.{ Completion, Completions, DefaultParsers, His
import sbt.internal.util.Types.{ const, idFun }
import sbt.internal.inc.classpath.ClasspathUtilities.toLoader
import sbt.internal.inc.ModuleUtilities
import sbt.internal.{ CommandRequest, CommandSource, CommandStatus }
import sbt.internal.{ Exec, CommandSource, CommandStatus }
import DefaultParsers._
import Function.tupled
import Command.applyEffect
@@ -193,17 +193,13 @@ object BasicCommands {
}
}
def server = Command.command(Server, Help.more(Server, ServerDetailed)) { s =>
def server = Command.command(Server, Help.more(Server, ServerDetailed)) { s0 =>
val exchange = State.exchange
exchange.channels foreach { x =>
x.runOrResume(CommandStatus(s, true))
x.setStatus(CommandStatus(s, true), None)
}
val CommandRequest(source, line) = exchange.blockUntilNextCommand
val newState = s.copy(onFailure = Some(Server), remainingCommands = line +: Server +: s.remainingCommands).setInteractive(true)
exchange.channels foreach { x =>
x.setStatus(CommandStatus(newState, false), Some(source))
}
val s1 = exchange.run(s0)
exchange.publishStatus(CommandStatus(s0, true), None)
val Exec(source, line) = exchange.blockUntilNextExec
val newState = s1.copy(onFailure = Some(Server), remainingCommands = line +: Server +: s1.remainingCommands).setInteractive(true)
exchange.publishStatus(CommandStatus(newState, false), Some(source))
if (line.trim.isEmpty) newState
else newState.clearGlobalLog
}