Rename early command to `early(command)`

Fixes #2734, Ref #1041
e93c4450a1 added a feature called early
command, which uses `--` as a prefix to denote some commands that runs
ahead of session loading. While the feature might be useful especially
for logging, `--` is too useful just for this purpose.
This commit is contained in:
Eugene Yokota 2016-09-15 01:34:41 -04:00
parent 57a655478f
commit 06724d1c4b
4 changed files with 12 additions and 10 deletions

View File

@ -60,21 +60,18 @@ ${runEarly(level.toString)}
* if no other commands are passed, interactive mode is still entered
"""
def runEarly(command: String) = {
val sep = if (command.isEmpty || Character.isLetter(command.charAt(0))) "" else " "
s"$EarlyCommand$sep$command"
}
def runEarly(command: String) = s"$EarlyCommand($command)"
private[sbt] def isEarlyCommand(s: String): Boolean = {
s.startsWith(EarlyCommand) && s != Compat.FailureWall && s != Compat.ClearOnFailure
s.startsWith(EarlyCommand + "(") && s.endsWith(")")
}
val EarlyCommand = "--"
val EarlyCommandBrief = (s"$EarlyCommand<command>", "Schedules a command to run before other commands on startup.")
val EarlyCommand = "early"
val EarlyCommandBrief = (s"$EarlyCommand(<command>)", "Schedules a command to run before other commands on startup.")
val EarlyCommandDetailed =
s"""$EarlyCommand<command>
s"""$EarlyCommand(<command>)
Schedules an early command, which will be run before other commands on the command line.
The order is preserved between all early commands, so `sbt --a --b` executes `a` and `b` in order.
The order is preserved between all early commands, so `sbt "early(a)" "early(b)"` executes `a` and `b` in order.
"""
def ReadCommand = "<"

View File

@ -24,7 +24,10 @@ object BasicCommands {
def ignore = Command.command(FailureWall)(idFun)
def early = Command.arb(earlyParser, earlyHelp) { (s, other) => other :: s }
private[this] def earlyParser = (s: State) => token(EarlyCommand).flatMap(_ => otherCommandParser(s))
private[this] def earlyParser = (s: State) =>
token(EarlyCommand + "(") flatMap { _ =>
otherCommandParser(s) <~ token(")")
}
private[this] def earlyHelp = Help(EarlyCommand, EarlyCommandBrief, EarlyCommandDetailed)
def help = Command.make(HelpCommand, helpBrief, helpDetailed)(helpParser)

View File

@ -0,0 +1 @@
lazy val root = (project in file("."))

View File

@ -0,0 +1 @@
> early(error)