mirror of https://github.com/sbt/sbt.git
Add `-error` etc for log levels with one hyphen
This commit is contained in:
parent
06724d1c4b
commit
9529f0c304
|
|
@ -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:
|
||||
|
|
@ -62,7 +62,9 @@ ${runEarly(level.toString)}
|
|||
|
||||
def runEarly(command: String) = s"$EarlyCommand($command)"
|
||||
private[sbt] def isEarlyCommand(s: String): Boolean = {
|
||||
s.startsWith(EarlyCommand + "(") && s.endsWith(")")
|
||||
val levelOptions = Level.values.toSeq map { "-" + _ }
|
||||
(s.startsWith(EarlyCommand + "(") && s.endsWith(")")) ||
|
||||
(levelOptions contains s)
|
||||
}
|
||||
|
||||
val EarlyCommand = "early"
|
||||
|
|
|
|||
|
|
@ -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,10 +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 { _ =>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
> -error
|
||||
> early(error)
|
||||
|
|
|
|||
Loading…
Reference in New Issue