Notify users about shell only if compile is present

This is a change in strategy.

The motivation is the need to find a good balance between:

  + informing the uninformed that would benefit from this information, &
  + not spamming the already informed

Making it dependent on "compile" being present in remainingCommands will
probably make it trigger for, for example, Maven users who are used to
running "mvn compile" and always run "sbt compile", and who therefore
are unneccesarily suffering terribly slow compile speeds by starting up
the jvm and sbt every time.

Fixes #3091
Fixes #3097
This commit is contained in:
Dale Wijnand
2017-05-26 21:33:49 -04:00
committed by Eugene Yokota
parent bb16c7b068
commit b54c0ff059
4 changed files with 114 additions and 64 deletions
+10 -7
View File
@@ -222,20 +222,23 @@ object State {
/** Provides operations and transformations on State. */
implicit def stateOps(s: State): StateOps = new StateOps {
def process(f: (Exec, State) => State): State = {
def doX(x: Exec, xs: List[Exec]) = {
log.debug(s"> $x")
f(x, s.copy(remainingCommands = xs, currentCommand = Some(x), history = x :: s.history))
def runCmd(cmd: Exec, remainingCommands: List[Exec]) = {
log.debug(s"> $cmd")
f(cmd,
s.copy(remainingCommands = remainingCommands,
currentCommand = Some(cmd),
history = cmd :: s.history))
}
def isInteractive = System.console() != null
def hasInput = System.console().reader().ready()
def isInteractive = System.console != null
def hasInput = Option(System.console) exists (_.reader.ready())
def hasShellCmd = s.definedCommands exists {
case c: SimpleCommand => c.name == Shell; case _ => false
}
s.remainingCommands match {
case List() =>
if (isInteractive && hasInput && hasShellCmd) doX(Exec(Shell, s.source), Nil)
if (isInteractive && hasInput && hasShellCmd) runCmd(Exec(Shell, s.source), Nil)
else exit(true)
case List(x, xs @ _*) => doX(x, xs.toList)
case List(x, xs @ _*) => runCmd(x, xs.toList)
}
}
def :::(newCommands: List[String]): State = ++:(newCommands map { Exec(_, s.source) })