mirror of https://github.com/sbt/sbt.git
Merge pull request #5823 from eed3si9n/wip/server_cmd
Add pseudo --server command
This commit is contained in:
commit
8053ebea73
|
|
@ -200,6 +200,10 @@ $AliasCommand name=
|
|||
Starts the server if it has not been started. This is intended to be used with
|
||||
-Dsbt.server.autostart=false."""
|
||||
|
||||
def ServerDetailed: String =
|
||||
"--server always runs sbt in not-daemon mode."
|
||||
def DashDashServer: String = "--server"
|
||||
|
||||
def OldShell: String = "oldshell"
|
||||
def OldShellDetailed = "Provides an interactive prompt from which commands can be run."
|
||||
|
||||
|
|
@ -208,7 +212,7 @@ $AliasCommand name=
|
|||
"Provides an interactive prompt from which commands can be run on a server."
|
||||
def DashClient: String = "-client"
|
||||
def DashDashClient: String = "--client"
|
||||
def CloseIOStreams: String = "--close-io-streams"
|
||||
def DashDashDetachStdio: String = "--detach-stdio"
|
||||
|
||||
def StashOnFailure: String = "sbtStashOnFailure"
|
||||
def PopOnFailure: String = "sbtPopOnFailure"
|
||||
|
|
|
|||
|
|
@ -129,8 +129,8 @@ object BasicKeys {
|
|||
"List of template resolver infos.",
|
||||
1000
|
||||
)
|
||||
private[sbt] val closeIOStreams = AttributeKey[Boolean](
|
||||
"close-io-streams",
|
||||
private[sbt] val detachStdio = AttributeKey[Boolean](
|
||||
"detach-stdio",
|
||||
"Toggles wheter or not to close system in, out and error when the server starts.",
|
||||
1000
|
||||
)
|
||||
|
|
|
|||
|
|
@ -298,7 +298,8 @@ class NetworkClient(
|
|||
term.isSupershellEnabled
|
||||
).mkString(",")
|
||||
|
||||
val cmd = arguments.sbtScript +: arguments.sbtArguments :+ BasicCommandStrings.CloseIOStreams
|
||||
val cmd = List(arguments.sbtScript) ++ arguments.sbtArguments ++
|
||||
List(BasicCommandStrings.DashDashDetachStdio, BasicCommandStrings.DashDashServer)
|
||||
val processBuilder =
|
||||
new ProcessBuilder(cmd: _*)
|
||||
.directory(arguments.baseDirectory)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ private[sbt] object xMain {
|
|||
}
|
||||
private[sbt] def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = {
|
||||
try {
|
||||
import BasicCommandStrings.{ DashClient, DashDashClient, runEarly }
|
||||
import BasicCommandStrings.{ DashClient, DashDashClient, DashDashServer, runEarly }
|
||||
import BasicCommands.early
|
||||
import BuiltinCommands.defaults
|
||||
import sbt.internal.CommandStrings.{ BootCommand, DefaultsCommand, InitCommand }
|
||||
|
|
@ -71,7 +71,9 @@ private[sbt] object xMain {
|
|||
}
|
||||
// if we detect -Dsbt.client=true or -client, run thin client.
|
||||
val clientModByEnv = SysProp.client
|
||||
val userCommands = configuration.arguments.map(_.trim)
|
||||
val userCommands = configuration.arguments
|
||||
.map(_.trim)
|
||||
.filterNot(_ == DashDashServer)
|
||||
val isClient: String => Boolean = cmd => (cmd == DashClient) || (cmd == DashDashClient)
|
||||
val isBsp: String => Boolean = cmd => (cmd == "-bsp") || (cmd == "--bsp")
|
||||
if (userCommands.exists(isBsp)) {
|
||||
|
|
@ -84,14 +86,14 @@ private[sbt] object xMain {
|
|||
NetworkClient.run(dealiasBaseDirectory(configuration), args)
|
||||
Exit(0)
|
||||
} else {
|
||||
val closeStreams = userCommands.exists(_ == BasicCommandStrings.CloseIOStreams)
|
||||
val detachStdio = userCommands.exists(_ == BasicCommandStrings.DashDashDetachStdio)
|
||||
val state0 = StandardMain
|
||||
.initialState(
|
||||
dealiasBaseDirectory(configuration),
|
||||
Seq(defaults, early),
|
||||
runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil
|
||||
)
|
||||
.put(BasicKeys.closeIOStreams, closeStreams)
|
||||
.put(BasicKeys.detachStdio, detachStdio)
|
||||
val state = bootServerSocket match {
|
||||
case Some(l) => state0.put(Keys.bootServerSocket, l)
|
||||
case _ => state0
|
||||
|
|
@ -228,7 +230,9 @@ object StandardMain {
|
|||
|
||||
import BasicCommandStrings.isEarlyCommand
|
||||
val userCommands =
|
||||
configuration.arguments.map(_.trim).filterNot(_ == BasicCommandStrings.CloseIOStreams)
|
||||
configuration.arguments
|
||||
.map(_.trim)
|
||||
.filterNot(_ == BasicCommandStrings.DashDashDetachStdio)
|
||||
val (earlyCommands, normalCommands) = (preCommands ++ userCommands).partition(isEarlyCommand)
|
||||
val commands = (earlyCommands ++ normalCommands).toList map { x =>
|
||||
Exec(x, None)
|
||||
|
|
|
|||
|
|
@ -246,7 +246,11 @@ private[sbt] final class CommandExchange {
|
|||
firstInstance.set(false)
|
||||
}
|
||||
Terminal.setBootStreams(null, null)
|
||||
if (s.get(BasicKeys.closeIOStreams).getOrElse(false)) Terminal.close()
|
||||
|
||||
if (s.get(BasicKeys.detachStdio).getOrElse(false)) {
|
||||
Terminal.close()
|
||||
}
|
||||
|
||||
s.get(Keys.bootServerSocket).foreach(_.close())
|
||||
}
|
||||
s.remove(Keys.bootServerSocket)
|
||||
|
|
|
|||
Loading…
Reference in New Issue