mirror of https://github.com/sbt/sbt.git
Merge pull request #2742 from eed3si9n/wip/early2
[sbt 0.13] Rename early command to `early(command)`
This commit is contained in:
commit
8f2a5a659a
|
|
@ -60,7 +60,7 @@ object BasicCommandStrings {
|
|||
This will be used as the default level for logging from commands, settings, and tasks.
|
||||
Any explicit `logLevel` configuration in a project overrides this setting.
|
||||
|
||||
${runEarly(level.toString)}
|
||||
-$level
|
||||
|
||||
Sets the global logging level as described above, but does so before any other commands are executed on startup, including project loading.
|
||||
This is useful as a startup option:
|
||||
|
|
@ -68,21 +68,23 @@ ${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
|
||||
val levelShortOptions = Level.values.toSeq map { "-" + _ }
|
||||
val levelLongOptions = Level.values.toSeq map { "--" + _ }
|
||||
(s.startsWith(EarlyCommand + "(") && s.endsWith(")")) ||
|
||||
(levelShortOptions contains s) ||
|
||||
(levelLongOptions contains s)
|
||||
}
|
||||
|
||||
val EarlyCommand = "--"
|
||||
val EarlyCommandBrief = (s"$EarlyCommand<command>", "Schedules a command to run before other commands on startup.")
|
||||
val OldEarlyCommand = "--"
|
||||
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 = "<"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,18 @@ 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 levelParser: Parser[String] =
|
||||
token(Level.Debug.toString) | token(Level.Info.toString) | token(Level.Warn.toString) | token(Level.Error.toString)
|
||||
private[this] def earlyParser: State => Parser[String] = (s: State) =>
|
||||
(token(EarlyCommand + "(") flatMap { _ =>
|
||||
otherCommandParser(s) <~ token(")")
|
||||
}) |
|
||||
(token("-") flatMap { _ =>
|
||||
levelParser
|
||||
}) |
|
||||
(token(OldEarlyCommand) flatMap { _ =>
|
||||
levelParser
|
||||
})
|
||||
private[this] def earlyHelp = Help(EarlyCommand, EarlyCommandBrief, EarlyCommandDetailed)
|
||||
|
||||
def help = Command.make(HelpCommand, helpBrief, helpDetailed)(helpParser)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
### Fixes with compatibility implications
|
||||
|
||||
- sbt 0.13.13 renames the early command that was added in 0.13.1 to `early(<command>)`. This fixes the regression [#1041][1041]. For backward compatibility `--error`, `--warn`, `--info`, and `--debug` will continue to function during 0.13 series, but it is strongly encouraged to migrate to the single hyphen option: `-error`, `-warn`, `-info`, and `-debug`. [@eed3si9n][@eed3si9n]
|
||||
|
||||
[1041]: https://github.com/sbt/sbt/issues/1041
|
||||
[@eed3si9n]: https://github.com/eed3si9n
|
||||
|
|
@ -0,0 +1 @@
|
|||
lazy val root = (project in file("."))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> early(error)
|
||||
> -error
|
||||
> --error
|
||||
Loading…
Reference in New Issue