From e06ada8fb7827500ad3cf6b5921a9895c7ea657e Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 19 Feb 2013 14:33:22 -0500 Subject: [PATCH] Add help for ++ and + commands --- main/src/main/scala/sbt/CommandStrings.scala | 28 ++++++++++++++++++++ main/src/main/scala/sbt/Cross.scala | 20 ++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/main/src/main/scala/sbt/CommandStrings.scala b/main/src/main/scala/sbt/CommandStrings.scala index 28a057c51..6b1ba99b4 100644 --- a/main/src/main/scala/sbt/CommandStrings.scala +++ b/main/src/main/scala/sbt/CommandStrings.scala @@ -241,4 +241,32 @@ load-commands -base ~/.sbt/commands (Path.userHome / sbtrc) :: (s.baseDir / sbtrc asFile) :: Nil + + val CrossCommand = "+" + val SwitchCommand = "++" + + def crossHelp: Help = Help.more(CrossCommand, CrossDetailed) + def switchHelp: Help = Help.more(SwitchCommand, SwitchDetailed) + + def CrossDetailed = +s"""$CrossCommand + Runs for each Scala version specified for cross-building. + + For each string in `crossScalaVersions` in the current project, this command sets the + `scalaVersion` of all projects to that version, reloads the build, and + executes . When finished, it reloads the build with the original + Scala version. + + See also `help $SwitchCommand` +""" + + def SwitchDetailed = +s"""$SwitchCommand [] + Changes the Scala version and runs a command. + + Sets the `scalaVersion` of all projects to and reloads the build. + If is provided, it is then executed. + + See also `help $CrossCommand` +""" } diff --git a/main/src/main/scala/sbt/Cross.scala b/main/src/main/scala/sbt/Cross.scala index 376ee7a05..3499dccf9 100644 --- a/main/src/main/scala/sbt/Cross.scala +++ b/main/src/main/scala/sbt/Cross.scala @@ -8,12 +8,16 @@ package sbt import DefaultParsers._ import Def.{ScopedKey, Setting} import Scope.GlobalScope + import CommandStrings.{CrossCommand,crossHelp,SwitchCommand,switchHelp} import java.io.File object Cross { - final val Switch = "++" - final val Cross = "+" + @deprecated("Moved to CommandStrings.Switch", "0.13.0") + final val Switch = CommandStrings.SwitchCommand + + @deprecated("Moved to CommandStrings.Cross", "0.13.0") + final val Cross = CommandStrings.CrossCommand def switchParser(state: State): Parser[(String, String)] = { @@ -24,11 +28,11 @@ object Cross val optionalCommand = token(Space ~> matched(state.combinedParser)) ?? "" spacedVersion ~ optionalCommand } - token(Switch ~> OptSpace) flatMap { sp => versionAndCommand(!sp.isEmpty) } + token(SwitchCommand ~> OptSpace) flatMap { sp => versionAndCommand(!sp.isEmpty) } } def spacedFirst(name: String) = opOrIDSpaced(name) ~ any.+ - lazy val switchVersion = Command.arb(requireSession(switchParser)) { case (state, (version, command)) => + lazy val switchVersion = Command.arb(requireSession(switchParser), switchHelp) { case (state, (version, command)) => val x = Project.extract(state) import x._ val home = IO.resolve(x.currentProject.base, new File(version)) @@ -64,14 +68,14 @@ object Cross } def crossParser(state: State): Parser[String] = - token(Cross <~ OptSpace) flatMap { _ => token(matched( state.combinedParser & spacedFirst(Cross) )) } + token(CrossCommand <~ OptSpace) flatMap { _ => token(matched( state.combinedParser & spacedFirst(CrossCommand) )) } - lazy val crossBuild = Command.arb(requireSession(crossParser)) { (state, command) => + lazy val crossBuild = Command.arb(requireSession(crossParser), crossHelp) { (state, command) => val x = Project.extract(state) import x._ val versions = crossVersions(state) - val current = scalaVersion in currentRef get structure.data map(Switch + " " + _) toList; - if(versions.isEmpty) command :: state else versions.map(Switch + " " + _ + " " + command) ::: current ::: state + val current = scalaVersion in currentRef get structure.data map(SwitchCommand + " " + _) toList; + if(versions.isEmpty) command :: state else versions.map(SwitchCommand + " " + _ + " " + command) ::: current ::: state } def crossVersions(state: State): Seq[String] = {