mirror of https://github.com/sbt/sbt.git
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:
parent
57a655478f
commit
06724d1c4b
|
|
@ -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 = "<"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
lazy val root = (project in file("."))
|
||||
|
|
@ -0,0 +1 @@
|
|||
> early(error)
|
||||
Loading…
Reference in New Issue