From 5cc4f2fadbb8eaba57efa1eec68eb8781c9cad8f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 15 Sep 2016 02:56:10 -0400 Subject: [PATCH 1/2] Use jEnv --- .java-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .java-version diff --git a/.java-version b/.java-version new file mode 100644 index 000000000..810ee4e91 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +1.6 From ee718e8700d48a6481818b7f3e012d85fc3cff9f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 15 Sep 2016 03:06:12 -0400 Subject: [PATCH 2/2] Rename early command to `early(command)` Backports #2741, Fixes #1041 e93c445 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. In addition, this adds log level commands with single `-`, such as -error to treat them as early commands; and keeps `--` variant for log level for backward compatibility. --- .../main/scala/sbt/BasicCommandStrings.scala | 22 ++++++++++--------- .../src/main/scala/sbt/BasicCommands.scala | 13 ++++++++++- notes/0.13.13/early.md | 6 +++++ .../sbt-test/actions/early-command/build.sbt | 1 + sbt/src/sbt-test/actions/early-command/test | 3 +++ 5 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 notes/0.13.13/early.md create mode 100644 sbt/src/sbt-test/actions/early-command/build.sbt create mode 100644 sbt/src/sbt-test/actions/early-command/test diff --git a/main/command/src/main/scala/sbt/BasicCommandStrings.scala b/main/command/src/main/scala/sbt/BasicCommandStrings.scala index 8750e027a..a5727c2ce 100644 --- a/main/command/src/main/scala/sbt/BasicCommandStrings.scala +++ b/main/command/src/main/scala/sbt/BasicCommandStrings.scala @@ -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", "Schedules a command to run before other commands on startup.") + val OldEarlyCommand = "--" + val EarlyCommand = "early" + val EarlyCommandBrief = (s"$EarlyCommand()", "Schedules a command to run before other commands on startup.") val EarlyCommandDetailed = - s"""$EarlyCommand + s"""$EarlyCommand() 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 = "<" diff --git a/main/command/src/main/scala/sbt/BasicCommands.scala b/main/command/src/main/scala/sbt/BasicCommands.scala index 1f1eada0f..cc6720df9 100644 --- a/main/command/src/main/scala/sbt/BasicCommands.scala +++ b/main/command/src/main/scala/sbt/BasicCommands.scala @@ -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) diff --git a/notes/0.13.13/early.md b/notes/0.13.13/early.md new file mode 100644 index 000000000..501720e14 --- /dev/null +++ b/notes/0.13.13/early.md @@ -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()`. 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 diff --git a/sbt/src/sbt-test/actions/early-command/build.sbt b/sbt/src/sbt-test/actions/early-command/build.sbt new file mode 100644 index 000000000..c128b140e --- /dev/null +++ b/sbt/src/sbt-test/actions/early-command/build.sbt @@ -0,0 +1 @@ +lazy val root = (project in file(".")) diff --git a/sbt/src/sbt-test/actions/early-command/test b/sbt/src/sbt-test/actions/early-command/test new file mode 100644 index 000000000..4029b7149 --- /dev/null +++ b/sbt/src/sbt-test/actions/early-command/test @@ -0,0 +1,3 @@ +> early(error) +> -error +> --error \ No newline at end of file