summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-26 19:58:48 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-26 19:58:48 -0800
commit02e64b943b90387993f8f7bd7e3cd265ee569d27 (patch)
tree05998f38121237fa7ec7bb4c7714cb69e0bb3fc6
parent5048981155836f9ec5225c9086e560f387df2459 (diff)
downloadmill-02e64b943b90387993f8f7bd7e3cd265ee569d27.tar.gz
mill-02e64b943b90387993f8f7bd7e3cd265ee569d27.tar.bz2
mill-02e64b943b90387993f8f7bd7e3cd265ee569d27.zip
force build REPL to be run using -i/--interactive
-rw-r--r--docs/pages/1 - Intro to Mill.md2
-rw-r--r--main/src/mill/Main.scala60
-rw-r--r--readme.md3
3 files changed, 36 insertions, 29 deletions
diff --git a/docs/pages/1 - Intro to Mill.md b/docs/pages/1 - Intro to Mill.md
index 65a83b8a..b2ffe0ec 100644
--- a/docs/pages/1 - Intro to Mill.md
+++ b/docs/pages/1 - Intro to Mill.md
@@ -398,7 +398,7 @@ your build file itself.
## The Build Repl
```bash
-$ mill
+$ mill -i
Loading...
@ foo
res1: foo.type = ammonite.predef.build#foo:2
diff --git a/main/src/mill/Main.scala b/main/src/mill/Main.scala
index 91fe862c..4a2ccba0 100644
--- a/main/src/mill/Main.scala
+++ b/main/src/mill/Main.scala
@@ -137,36 +137,42 @@ object Main {
case Right((cliConfig, leftoverArgs)) =>
val repl = leftoverArgs.isEmpty
- val config =
- if(!repl) cliConfig
- else cliConfig.copy(
- predefCode =
- """import $file.build, build._
- |implicit val replApplyHandler = mill.main.ReplApplyHandler(
- | interp.colors(),
- | repl.pprinter(),
- | build.millSelf.get,
- | build.millDiscover
- |)
- |repl.pprinter() = replApplyHandler.pprinter
- |import replApplyHandler.generatedEval._
- |
- """.stripMargin,
- welcomeBanner = None
+ if (repl && stdin == DummyInputStream) {
+ stderr.println("Build repl needs to be run with the -i/--interactive flag")
+ (false, stateCache)
+ }else{
+ val config =
+ if(!repl) cliConfig
+ else cliConfig.copy(
+ predefCode =
+ """import $file.build, build._
+ |implicit val replApplyHandler = mill.main.ReplApplyHandler(
+ | interp.colors(),
+ | repl.pprinter(),
+ | build.millSelf.get,
+ | build.millDiscover
+ |)
+ |repl.pprinter() = replApplyHandler.pprinter
+ |import replApplyHandler.generatedEval._
+ |
+ """.stripMargin,
+ welcomeBanner = None
+ )
+
+ val runner = new mill.main.MainRunner(
+ config.copy(colored = Some(mainInteractive)),
+ stdout, stderr, stdin,
+ stateCache
)
- val runner = new mill.main.MainRunner(
- config.copy(colored = Some(mainInteractive)),
- stdout, stderr, stdin,
- stateCache
- )
+ if (repl){
+ runner.printInfo("Loading...")
+ (runner.watchLoop(isRepl = true, printing = false, _.run()), runner.stateCache)
+ } else {
+ (runner.runScript(pwd / "build.sc", leftoverArgs), runner.stateCache)
+ }
+ }
- if (repl){
- runner.printInfo("Loading...")
- (runner.watchLoop(isRepl = true, printing = false, _.run()), runner.stateCache)
- } else {
- (runner.runScript(pwd / "build.sc", leftoverArgs), runner.stateCache)
- }
}
}
}
diff --git a/readme.md b/readme.md
index 8a416035..fa68fd85 100644
--- a/readme.md
+++ b/readme.md
@@ -177,7 +177,8 @@ Mill provides a build REPL, which lets you explore the build interactively and
run `Target`s from Scala code:
```scala
-lihaoyi mill$ target/bin/mill
+$ mill -i
+
Loading...
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/replBridge.sc