mirror of https://github.com/sbt/sbt.git
Merge pull request #2741 from eed3si9n/wip/early
[sbt 1.0] Rename early command to `early(command)`
This commit is contained in:
commit
5e80016eb0
|
|
@ -10,6 +10,8 @@ Migration notes
|
|||
- Removed the pre-0.13.7 *.sbt file parser (previously available under `-Dsbt.parser.simple=true`)
|
||||
- Removed old, hyphen-separated key names (use `publishLocal` instead of `publish-local`)
|
||||
- Removes no-longer-documented old operators `<<=`, `<+=`, and `<++=`.
|
||||
- Renames early command feature from `--<command>` to `early(<command>)`.
|
||||
- Log options `-error`, `-warn`, `-info`, `-debug` are added as shorthand for `"early(error)"` etc.
|
||||
|
||||
#### Additional import required
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,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:
|
||||
|
|
@ -60,21 +60,20 @@ ${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 levelOptions = Level.values.toSeq map { "-" + _ }
|
||||
(s.startsWith(EarlyCommand + "(") && s.endsWith(")")) ||
|
||||
(levelOptions contains s)
|
||||
}
|
||||
|
||||
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 = "<"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.util.Level
|
||||
import sbt.internal.util.{ AttributeKey, FullReader }
|
||||
import sbt.internal.util.complete.{ Completion, Completions, DefaultParsers, History => CHistory, HistoryCommands, Parser, TokenCompletions }
|
||||
import sbt.internal.util.Types.{ const, idFun }
|
||||
|
|
@ -24,7 +25,15 @@ 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
|
||||
})
|
||||
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,2 @@
|
|||
> -error
|
||||
> early(error)
|
||||
Loading…
Reference in New Issue