我希望我错过了一些东西,因为当某个程序在sbt中运行时,按键不会回显到屏幕上。 这是一个例子:
object ConsoleTest extends App {
println("Enter a line:")
val input = Console.readLine()
println("You entered: " + input)
}
当我编译这个简单的代码并从命令行(在sbt之外)运行它时,我看到按键,因为我输入它们进行输入,一切正常。
不幸的是,当我使用sbt编译&运行相同的代码,它根本不回显屏幕上的按键。这是令人不安的经历
还有其他人经历过这种差异吗?
我做了一些搜索,看看是否有人遇到这个,以及是否有一个sbt运行时参数允许按键回显。到目前为止没有运气
我使用的是sbt-0.13.2,上面代码的Java版本也遇到了同样的区别,因此它看起来局限于在sbt环境中运行。
任何见解都表示赞赏。
答案 0 :(得分:2)
这个问题是2.5岁,仍然没有答案,所以这里有:)
我使用Scala 2.12.1,SBT 0.13.13.1在Windows 10上进行了测试。测试程序在Cmd和WSL的bash下运行良好。
历史上,这个问题一直是JLine问题的症状。您可以使用jline.terminal
Java系统变量将JLine设置覆盖为auto
,none
和windows
等值。 Here are the complete docs
以下是一些如何指定各种设置的示例:
C:\work\experiments\sbt\optionTest>sbt run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\work\experiments\sbt\optionTest\project
[info] Updating {file:/C:/work/experiments/sbt/optionTest/project/}optiontest-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to change-me (in build file:/C:/work/experiments/sbt/optionTest/)
[warn] there was one deprecation warning (since 2.11.0); re-run with -deprecation for details
[warn] one warning found
Enter a line:
asdf
You entered: asdf
[success] Total time: 46 s, completed Jan 7, 2017 1:27:27 PM
C:\work\experiments\sbt\optionTest> sbt "-Djline.terminal=none" run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\work\experiments\sbt\optionTest\project
[info] Set current project to change-me (in build file:/C:/work/experiments/sbt/optionTest/)
Enter a line:
asdf
You entered: asdf
[success] Total time: 3 s, completed Jan 7, 2017 1:28:12 PM
C:\work\experiments\sbt\optionTest> sbt "-Djline.terminal=windows" run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\work\experiments\sbt\optionTest\project
[info] Set current project to change-me (in build file:/C:/work/experiments/sbt/optionTest/)
Enter a line:
asdf
You entered: asdf
[success] Total time: 3 s, completed Jan 7, 2017 1:28:26 PM