Merge pull request #4162 from holdenk/support-double-dash-for-logging-levels

Support -- for log levels
This commit is contained in:
Dale Wijnand 2018-05-23 12:13:23 +01:00 committed by GitHub
commit d8e27747d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -67,7 +67,7 @@ $HelpCommand <regular expression>
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.
-$level
-$level OR --$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:
@ -77,7 +77,9 @@ $HelpCommand <regular expression>
def runEarly(command: String) = s"$EarlyCommand($command)"
private[sbt] def isEarlyCommand(s: String): Boolean = {
val levelOptions = Level.values.toSeq map { "-" + _ }
val levelOptions = Level.values.toSeq flatMap { elem =>
List("-" + elem, "--" + elem)
}
(s.startsWith(EarlyCommand + "(") && s.endsWith(")")) ||
(levelOptions contains s)
}

View File

@ -69,7 +69,8 @@ object BasicCommands {
private[this] def earlyParser: State => Parser[String] = (s: State) => {
val p1 = token(EarlyCommand + "(") flatMap (_ => otherCommandParser(s) <~ token(")"))
val p2 = token("-") flatMap (_ => levelParser)
p1 | p2
val p3 = token("--") flatMap (_ => levelParser)
p1 | p2 | p3
}
private[this] def earlyHelp = Help(EarlyCommand, EarlyCommandBrief, EarlyCommandDetailed)

View File

@ -1,2 +1,3 @@
> -error
> early(error)
> --error