From 272ada1e74b9651051f6e132a8da35b4215cd4b6 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 22 Sep 2016 20:23:26 -0400 Subject: [PATCH] Improve `show` when key returns a `Seq` This changes the output to: ``` > show externalDependencyClasspath [info] Updating {file:/xxx/hello/}root... [info] Resolving jline#jline;2.12.1 ... [info] Done updating. [info] * Attributed(/Users/xxx/.sbt/boot/scala-2.11.8/lib/scala-library.jar) [info] * Attributed(/Users/xxx/.ivy2/cache/commons-io/commons-io/jars/commons-io- 2.4.jar) ``` --- main/src/main/scala/sbt/Aggregation.scala | 11 ++++++++--- notes/0.13.13.markdown | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/Aggregation.scala b/main/src/main/scala/sbt/Aggregation.scala index d251b375f..616540ab8 100644 --- a/main/src/main/scala/sbt/Aggregation.scala +++ b/main/src/main/scala/sbt/Aggregation.scala @@ -18,11 +18,16 @@ final object Aggregation { final case class KeyValue[+T](key: ScopedKey[_], value: T) def defaultShow(state: State, showTasks: Boolean): ShowConfig = ShowConfig(settingValues = true, taskValues = showTasks, s => state.log.info(s), success = true) - def printSettings(xs: Seq[KeyValue[_]], print: String => Unit)(implicit display: Show[ScopedKey[_]]) = + + def printSettings(xs: Seq[KeyValue[_]], print: String => Unit)(implicit display: Show[ScopedKey[_]]) = { + def showSeq = !java.lang.Boolean.getBoolean("sbt.disable.show.seq") xs match { - case KeyValue(_, x) :: Nil => print(x.toString) - case _ => xs foreach { case KeyValue(key, value) => print(display(key) + "\n\t" + value.toString) } + case KeyValue(_, x: Seq[_]) :: Nil if showSeq => print(x.mkString("* ", "\n* ", "")) + case KeyValue(_, x) :: Nil => print(x.toString) + case _ => xs foreach { case KeyValue(key, value) => print(display(key) + "\n\t" + value.toString) } } + } + type Values[T] = Seq[KeyValue[T]] type AnyKeys = Values[_] def seqParser[T](ps: Values[Parser[T]]): Parser[Seq[KeyValue[T]]] = seq(ps.map { case KeyValue(k, p) => p.map(v => KeyValue(k, v)) }) diff --git a/notes/0.13.13.markdown b/notes/0.13.13.markdown index 63136326d..fd9f2a9cd 100644 --- a/notes/0.13.13.markdown +++ b/notes/0.13.13.markdown @@ -7,6 +7,7 @@ which returns `A` by evaluating the task. Just in case `InputTask[A]` is needed, `.inputTaskValue` method is now provided. [#2709][2709] by [@eed3si9n][@eed3si9n] - 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 the 0.13 series, but it is strongly encouraged to migrate to the single hyphen options: `-error`, `-warn`, `-info`, and `-debug`. [#2742][2742] by [@eed3si9n][@eed3si9n] +- Improve `show` when key returns a `Seq` by showing the elements one per line. Disable with `-Dsbt.disable.show.seq=true`. [#2755][2755] by [@eed3si9n][@eed3si9n] ### Improvements @@ -121,6 +122,7 @@ For `<+=` and `<++=`, use `+= { x.value }` and `++= { x.value }`. [2738]: https://github.com/sbt/sbt/issues/2738 [2742]: https://github.com/sbt/sbt/pull/2742 [2746]: https://github.com/sbt/sbt/pull/2746 + [2755]: https://github.com/sbt/sbt/pull/2755 [110]: https://github.com/sbt/sbt-launcher-package/pull/110 [111]: https://github.com/sbt/sbt-launcher-package/pull/111 [sbt-ivy-22]: https://github.com/sbt/ivy/pull/22