Merge pull request #3876 from eed3si9n/wip/jlineinit

Fix tab completion running `sbt console`
This commit is contained in:
eugene yokota 2018-01-22 14:14:35 -05:00 committed by GitHub
commit 5d89795657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 14 deletions

View File

@ -9,7 +9,7 @@ def buildLevelSettings: Seq[Setting[_]] =
inThisBuild( inThisBuild(
Seq( Seq(
organization := "org.scala-sbt", organization := "org.scala-sbt",
version := "1.1.0-SNAPSHOT", version := "1.1.1-SNAPSHOT",
description := "sbt is an interactive build tool", description := "sbt is an interactive build tool",
bintrayOrganization := Some("sbt"), bintrayOrganization := Some("sbt"),
bintrayRepository := { bintrayRepository := {

View File

@ -1366,12 +1366,13 @@ object Defaults extends BuildCommon {
(compilers in task).value.scalac match { (compilers in task).value.scalac match {
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala")) case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala"))
} }
(new Console(compiler))(cpFiles, val sc = (scalacOptions in task).value
(scalacOptions in task).value, val ic = (initialCommands in task).value
loader, val cc = (cleanupCommands in task).value
(initialCommands in task).value, JLine.usingTerminal { _ =>
(cleanupCommands in task).value)()(s.log).get (new Console(compiler))(cpFiles, sc, loader, ic, cc)()(s.log).get
println() println()
}
} }
private[this] def exported(w: PrintWriter, command: String): Seq[String] => Unit = private[this] def exported(w: PrintWriter, command: String): Seq[String] => Unit =

View File

@ -9,6 +9,7 @@ package sbt
package internal package internal
import sbt.util.Logger import sbt.util.Logger
import sbt.internal.util.JLine
import sbt.internal.inc.{ ScalaInstance, ZincUtil } import sbt.internal.inc.{ ScalaInstance, ZincUtil }
import xsbti.compile.ClasspathOptionsUtil import xsbti.compile.ClasspathOptionsUtil
@ -42,13 +43,17 @@ object ConsoleProject {
val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1)) val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1))
val importString = imports.mkString("", ";\n", ";\n\n") val importString = imports.mkString("", ";\n", ";\n\n")
val initCommands = importString + extra val initCommands = importString + extra
// TODO - Hook up dsl classpath correctly...
(new Console(compiler))( JLine.usingTerminal { _ =>
unit.classpath, // TODO - Hook up dsl classpath correctly...
options, (new Console(compiler))(
initCommands, unit.classpath,
cleanupCommands options,
)(Some(unit.loader), bindings) initCommands,
cleanupCommands
)(Some(unit.loader), bindings)
}
()
} }
/** Conveniences for consoleProject that shouldn't normally be used for builds. */ /** Conveniences for consoleProject that shouldn't normally be used for builds. */

View File

@ -0,0 +1,13 @@
[@eed3si9n]: https://github.com/eed3si9n
[3841]: https://github.com/sbt/sbt/issues/3841
[3876]: https://github.com/sbt/sbt/pull/3876
### Fixes with compatibility implications
### Improvements
### Bug fixes
- Fixes tab completion in `console` while running in batch mode as `sbt console`. [#3841][3841]/[#3876][3876] by [@eed3si9n][@eed3si9n]