How to run a command when sbt starts and keep the session active?

こ雲淡風輕ζ 提交于 2020-01-02 13:14:33

问题


If we define initialCommands in console += "1+1" this will run after console is executed.

Is it possible to run a command after sbt starts, like initialCommands in sbtStartup += "console" to enter the console automatically?

I'd like to keep the session (after executing the command) active.


回答1:


from http://www.scala-sbt.org/0.13.5/docs/faq.html#how-can-i-take-action-when-the-project-is-loaded-or-unloaded

http://www.scala-sbt.org/0.13.5/api/index.html#sbt.StateOps

onLoad in Global := {
  ((s: State) => { "console" :: s }) compose (onLoad in Global).value
}



回答2:


Executing sbt launcher with a task or command on command line executes it after sbt is up and running. sbt console would give you what you're after yet sbt will shutdown after the task/command finishes (I can only suspect that was the intent of the OP).



来源:https://stackoverflow.com/questions/25388592/how-to-run-a-command-when-sbt-starts-and-keep-the-session-active

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!