mirror of https://github.com/sbt/sbt.git
add 'about' command with sbt versions and Scala versions
This commit is contained in:
parent
109326d34b
commit
2d4d27e529
|
|
@ -33,6 +33,7 @@ object CommandSupport
|
||||||
/** The prefix used to identify a request to execute the remaining input on source changes.*/
|
/** The prefix used to identify a request to execute the remaining input on source changes.*/
|
||||||
val ContinuousExecutePrefix = "~"
|
val ContinuousExecutePrefix = "~"
|
||||||
val HelpCommand = "help"
|
val HelpCommand = "help"
|
||||||
|
val AboutCommand = "about"
|
||||||
val TasksCommand = "tasks"
|
val TasksCommand = "tasks"
|
||||||
val ProjectCommand = "project"
|
val ProjectCommand = "project"
|
||||||
val ProjectsCommand = "projects"
|
val ProjectsCommand = "projects"
|
||||||
|
|
@ -121,6 +122,9 @@ Tasks produce values. Use the 'show' command to run the task and print the resu
|
||||||
def helpBrief = (HelpCommand + " command*", "Displays this help message or prints detailed help on requested commands.")
|
def helpBrief = (HelpCommand + " command*", "Displays this help message or prints detailed help on requested commands.")
|
||||||
def helpDetailed = "If an argument is provided, this prints detailed help for that command.\nOtherwise, this prints a help summary."
|
def helpDetailed = "If an argument is provided, this prints detailed help for that command.\nOtherwise, this prints a help summary."
|
||||||
|
|
||||||
|
def aboutBrief = "Displays basic information about sbt and the build."
|
||||||
|
def aboutDetailed = aboutBrief
|
||||||
|
|
||||||
def projectBrief = (ProjectCommand + " [project]", "Displays the current project or changes to the provided `project`.")
|
def projectBrief = (ProjectCommand + " [project]", "Displays the current project or changes to the provided `project`.")
|
||||||
def projectDetailed =
|
def projectDetailed =
|
||||||
ProjectCommand +
|
ProjectCommand +
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ object BuiltinCommands
|
||||||
|
|
||||||
def ConsoleCommands: Seq[Command] = Seq(ignore, exit, IvyConsole.command, act, nop)
|
def ConsoleCommands: Seq[Command] = Seq(ignore, exit, IvyConsole.command, act, nop)
|
||||||
def ScriptCommands: Seq[Command] = Seq(ignore, exit, Script.command, act, nop)
|
def ScriptCommands: Seq[Command] = Seq(ignore, exit, Script.command, act, nop)
|
||||||
def DefaultCommands: Seq[Command] = Seq(ignore, help, reboot, read, history, continuous, exit, loadProject, loadProjectImpl, loadFailed, Cross.crossBuild, Cross.switchVersion,
|
def DefaultCommands: Seq[Command] = Seq(ignore, help, about, reboot, read, history, continuous, exit, loadProject, loadProjectImpl, loadFailed, Cross.crossBuild, Cross.switchVersion,
|
||||||
projects, project, setOnFailure, clearOnFailure, ifLast, multi, shell, set, tasks, inspect, eval, alias, append, last, lastGrep, nop, sessionCommand, act)
|
projects, project, setOnFailure, clearOnFailure, ifLast, multi, shell, set, tasks, inspect, eval, alias, append, last, lastGrep, nop, sessionCommand, act)
|
||||||
def DefaultBootCommands: Seq[String] = LoadProject :: (IfLast + " " + Shell) :: Nil
|
def DefaultBootCommands: Seq[String] = LoadProject :: (IfLast + " " + Shell) :: Nil
|
||||||
|
|
||||||
|
|
@ -90,6 +90,7 @@ object BuiltinCommands
|
||||||
h.detail match { case (commands, value) => if( selected exists commands ) Some(value) else None }
|
h.detail match { case (commands, value) => if( selected exists commands ) Some(value) else None }
|
||||||
|
|
||||||
def help = Command.make(HelpCommand, helpBrief, helpDetailed)(helpParser)
|
def help = Command.make(HelpCommand, helpBrief, helpDetailed)(helpParser)
|
||||||
|
def about = Command.command(AboutCommand, aboutBrief, aboutDetailed) { s => logger(s).info(aboutString(s)); s }
|
||||||
|
|
||||||
def helpParser(s: State) =
|
def helpParser(s: State) =
|
||||||
{
|
{
|
||||||
|
|
@ -109,6 +110,26 @@ object BuiltinCommands
|
||||||
System.out.println(message)
|
System.out.println(message)
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
def aboutProject(s: State): String =
|
||||||
|
if(Project.isProjectLoaded(s))
|
||||||
|
{
|
||||||
|
val e = Project.extract(s)
|
||||||
|
val current = "The current project is " + Project.display(e.currentRef) + "\n"
|
||||||
|
val built = e.getOpt(Keys.scalaVersion) match {
|
||||||
|
case Some(sv) => "The current project is built against Scala " + sv + "\n"
|
||||||
|
case None => ""
|
||||||
|
}
|
||||||
|
current + built
|
||||||
|
}
|
||||||
|
else "No project is currently loaded.\n"
|
||||||
|
|
||||||
def tasks = Command.command(TasksCommand, tasksBrief, tasksDetailed) { s =>
|
def tasks = Command.command(TasksCommand, tasksBrief, tasksDetailed) { s =>
|
||||||
System.out.println(tasksPreamble)
|
System.out.println(tasksPreamble)
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,9 @@ final case class Extracted(structure: BuildStructure, session: SessionSettings,
|
||||||
lazy val currentProject = currentUnit defined currentRef.project
|
lazy val currentProject = currentUnit defined currentRef.project
|
||||||
lazy val currentLoader: ClassLoader = currentUnit.loader
|
lazy val currentLoader: ClassLoader = currentUnit.loader
|
||||||
def get[T](key: ScopedTask[T]): Task[T] = get(key.task)
|
def get[T](key: ScopedTask[T]): Task[T] = get(key.task)
|
||||||
def get[T](key: ScopedSetting[T]): T =
|
def get[T](key: ScopedSetting[T]): T = getOrError(inCurrent(key), key.key)
|
||||||
{
|
def getOpt[T](key: ScopedSetting[T]): Option[T] = structure.data.get(inCurrent(key), key.key)
|
||||||
val scope = if(key.scope.project == This) key.scope.copy(project = Select(currentRef)) else key.scope
|
private[this] def inCurrent[T](key: ScopedSetting[T]): Scope = if(key.scope.project == This) key.scope.copy(project = Select(currentRef)) else key.scope
|
||||||
getOrError(scope, key.key)
|
|
||||||
}
|
|
||||||
def evalTask[T](key: ScopedTask[T], state: State): T =
|
def evalTask[T](key: ScopedTask[T], state: State): T =
|
||||||
{
|
{
|
||||||
import EvaluateTask._
|
import EvaluateTask._
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue