From 69d45b7f5f774f92bfaee4d5f496d5f15eaea9aa Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Fri, 2 Mar 2012 00:59:41 +0530 Subject: [PATCH] Use `provider.id.name` instead of hard-coded 'sbt' in `aboutString` Also rearrange and reformat a bit --- main/Main.scala | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/main/Main.scala b/main/Main.scala index f6737613e..69afb69f9 100644 --- a/main/Main.scala +++ b/main/Main.scala @@ -82,14 +82,9 @@ object BuiltinCommands delegateToAlias(BootCommand, success(orElse) )(s) } + def sbtName(s: State): String = s.configuration.provider.id.name def sbtVersion(s: State): String = s.configuration.provider.id.version def scalaVersion(s: State): String = s.configuration.provider.scalaProvider.version - def aboutString(s: State): String = - { - "This is sbt " + sbtVersion(s) + "\n" + - aboutProject(s) + - "sbt, sbt plugins, and build definitions are using Scala " + scalaVersion(s) + "\n" - } def aboutProject(s: State): String = if(Project.isProjectLoaded(s)) { @@ -99,12 +94,12 @@ object BuiltinCommands val built = if(sc.isEmpty) "" else "The current project is built against " + sc + "\n" current + built + aboutPlugins(e) } - else "No project is currently loaded.\n" + else "No project is currently loaded" def aboutPlugins(e: Extracted): String = { val allPluginNames = e.structure.units.values.flatMap(_.unit.plugins.pluginNames).toSeq.distinct - if(allPluginNames.isEmpty) "" else allPluginNames.mkString("Available Plugins: ", ", ", "\n") + if(allPluginNames.isEmpty) "" else allPluginNames.mkString("Available Plugins: ", ", ", "") } def aboutScala(s: State, e: Extracted): String = { @@ -119,6 +114,14 @@ object BuiltinCommands case (None, None, None) => "" } } + def aboutString(s: State): String = + { + val (name, ver, scalaVer, about) = (sbtName(s), sbtVersion(s), scalaVersion(s), aboutProject(s)) + """This is %s %s + |%s + |%s, %s plugins, and build definitions are using Scala %s + |""".stripMargin.format(name, ver, about, name, name, scalaVer) + } private[this] def selectScalaVersion(sv: Option[String], si: ScalaInstance): String = sv match { case Some(si.version) => si.version; case _ => si.actualVersion } private[this] def quiet[T](t: => T): Option[T] = try { Some(t) } catch { case e: Exception => None }