-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly wire stdin in client-server mode and enable "Enter to Re-run" for mill -w #1621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another great change! I love that it fixes the need to use --interactive
for interactive commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Notably, even the interactive Scala console works without $ ./mill -i dev.run scratch foo.console
[90/647] de.tobiasroeser.mill.vcs.version.VcsVersion.vcsState
[647/647] dev.run
[39/39] foo.console
Welcome to Scala 2.13.2 (OpenJDK 64-Bit Server VM, Java 11.0.7).
Type in expressions for evaluation. Or try :help.
Dec 15, 2021 8:59:31 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
1
scala> + 1
val res0: Int = 2
scala> println(123, 456)
println(123, 456)(123,456) Not 100%, |
…" for mill -w (com-lihaoyi#1621) This gets rid of our custom `watchAndWait` logic, standardizing it with what's upstream in Ammonite and allowing Mill to use the "Enter to re-run" functionality that was introduced in Ammonite 2.5.0. While this worked for `./mill -i` out of the box, some work was necessary to get it working for Mill's client-server mode. This fixes the wiring for the socket's stdin to ensure it gets plumbed through, and works around the broken `available()` implementation in the `UnixDomainSocketInputStream` by proxying it via an `InputPumper`. Tested manually: ``` lihaoyi mill$ ./mill -i dev.run scratch -w foo.run [90/647] de.tobiasroeser.mill.vcs.version.VcsVersion.vcsState [647/647] dev.run [44/44] foo.run false Watching for changes to 4 paths... (Enter to re-run, Ctrl-C to exit) <ENTER> [44/44] foo.run false Watching for changes to 4 paths... (Enter to re-run, Ctrl-C to exit) <ENTER> [44/44] foo.run false Watching for changes to 4 paths... (Enter to re-run, Ctrl-C to exit) <ENTER> [44/44] foo.run false Watching for changes to 4 paths... (Enter to re-run, Ctrl-C to exit) <Ctrl-C> Host JVM shutdown. Forcefully destroying subprocess ... ``` Notably, this change also allows you to run interactive `mill foo.run` programs without using `-i`, e.g. using this modified `scratch/src/Foo.scala`: ``` package foo object Foo{ def main(args: Array[String]): Unit = { println("enter any character: ") val c = System.in.read().toChar println("c: [" + c + "]") } } ``` ```bash lihaoyi mill$ ./mill -i dev.run scratch -w foo.run ... [44/44] foo.run enter any character: g<ENTER> c: [g] Watching for changes to 4 paths... (Enter to re-run, Ctrl-C to exit) ```
This gets rid of our custom
watchAndWait
logic, standardizing it with what's upstream in Ammonite and allowing Mill to use the "Enter to re-run" functionality that was introduced in Ammonite 2.5.0.While this worked for
./mill -i
out of the box, some work was necessary to get it working for Mill's client-server mode. This fixes the wiring for the socket's stdin to ensure it gets plumbed through, and works around the brokenavailable()
implementation in theUnixDomainSocketInputStream
by proxying it via anInputPumper
.Tested manually:
Notably, this change also allows you to run interactive
mill foo.run
programs without using-i
, e.g. using this modifiedscratch/src/Foo.scala
: