如何在 sbt 启动时运行命令并保持会话处于活动状态? [英] How to run a command when sbt starts and keep the session active?

查看:34
本文介绍了如何在 sbt 启动时运行命令并保持会话处于活动状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们在控制台中定义 initialCommands += "1+1" 这将在控制台执行后运行.

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

是否可以在sbt启动后运行一个命令,比如initialCommands in sbtStartup += "console" 自动进入控制台?

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.

推荐答案

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

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
}

这篇关于如何在 sbt 启动时运行命令并保持会话处于活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆