Merge pull request #4023 from dwijnand/reintroduce-Command.process

Re-introduce Command.process
This commit is contained in:
Dale Wijnand 2018-04-03 14:57:29 +01:00 committed by GitHub
commit dfbb67e7d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -163,6 +163,16 @@ object Command {
case Some(c) => c(state)
})
def process(command: String, state: State): State = {
val parser = combine(state.definedCommands)
parse(command, parser(state)) match {
case Right(s) => s() // apply command. command side effects happen here
case Left(errMsg) =>
state.log error errMsg
state.fail
}
}
def invalidValue(label: String, allowed: Iterable[String])(value: String): String =
s"Not a valid $label: $value" + similar(value, allowed)

View File

@ -17,7 +17,6 @@ import scala.util.control.NonFatal
import sbt.io.{ IO, Using }
import sbt.internal.util.{ ErrorHandling, GlobalLogBacking }
import sbt.internal.util.complete.Parser
import sbt.internal.langserver.ErrorCodes
import sbt.util.Logger
import sbt.protocol._
@ -148,13 +147,7 @@ object MainLoop {
val channelName = exec.source map (_.channelName)
StandardMain.exchange publishEventMessage
ExecStatusEvent("Processing", channelName, exec.execId, Vector())
val parser = Command combine state.definedCommands
val newState = Parser.parse(exec.commandLine, parser(state)) match {
case Right(s) => s() // apply command. command side effects happen here
case Left(errMsg) =>
state.log error errMsg
state.fail
}
val newState = Command.process(exec.commandLine, state)
val doneEvent = ExecStatusEvent(
"Done",
channelName,