All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sbt.internal.CommandStrings.scala Maven / Gradle / Ivy

The newest version!
/* sbt -- Simple Build Tool
 * Copyright 2010  Mark Harrah
 */
package sbt
package internal

import sbt.io.Path

object CommandStrings {
  /** The prefix used to identify a request to execute the remaining input on source changes.*/
  val AboutCommand = "about"
  val TasksCommand = "tasks"
  val SettingsCommand = "settings"
  val ProjectCommand = "project"
  val ProjectsCommand = "projects"
  val ShowCommand = "show"
  val MultiTaskCommand = "all"
  val BootCommand = "boot"

  val EvalCommand = "eval"
  val evalBrief = (EvalCommand + " ", "Evaluates a Scala expression and prints the result and type.")
  val evalDetailed =
    EvalCommand + """ 

	Evaluates the given Scala expression and prints the result and type."""

  @deprecated("Misnomer: was only for `show`.  Use showBrief.", "0.13.2")
  def actBrief = showBrief
  @deprecated("Misnomer: was only for `show`.  Use showDetailed.", "0.13.2")
  def actDetailed = showDetailed

  def actHelp = showHelp ++ multiTaskHelp

  def multiTaskHelp = Help(MultiTaskCommand, (multiTaskSyntax, multiTaskBrief), multiTaskDetailed)
  def multiTaskDetailed =
    s"""$multiTaskSyntax

	$multiTaskBrief"""
  def multiTaskSyntax = s"""$MultiTaskCommand +"""
  def multiTaskBrief = """Executes all of the specified tasks concurrently."""

  def showHelp = Help(ShowCommand, (s"$ShowCommand ", showBrief), showDetailed)
  def showBrief = "Displays the result of evaluating the setting or task associated with 'key'."
  def showDetailed =
    s"""$ShowCommand 

	Displays the value of the specified setting.

$ShowCommand 

	Evaluates the specified task and display the value returned by the task."""

  val PluginsCommand = "plugins"
  val PluginCommand = "plugin"
  def pluginsBrief = "Lists currently available plugins."
  def pluginsDetailed = pluginsBrief // TODO: expand

  val LastCommand = "last"
  val LastGrepCommand = "last-grep"
  val ExportCommand = "export"
  val ExportStream = "export"

  val lastGrepBrief = (LastGrepCommand, "Shows lines from the last output for 'key' that match 'pattern'.")
  val lastGrepDetailed =
    LastGrepCommand + """ 
	Displays lines from the logging of previous commands that match `pattern`.

""" + LastGrepCommand + """  [key]
	Displays lines from logging associated with `key` that match `pattern`.  The key typically refers to a task (for example, test:compile).  The logging that is displayed is restricted to the logging for that particular task.

	 is a regular expression interpreted by java.util.Pattern.  Matching text is highlighted (when highlighting is supported and enabled).
	See also '""" + LastCommand + "'."

  val lastBrief = (LastCommand, "Displays output from a previous command or the output from a specific task.")
  val lastDetailed =
    LastCommand + """
	Prints the logging for the previous command, typically at a more verbose level.

""" + LastCommand + """ 
	Prints the logging associated with the provided key.  The key typically refers to a task (for example, test:compile).  The logging that is displayed is restricted to the logging for that particular task.

	See also '""" + LastGrepCommand + "'."

  val exportBrief = (ExportCommand + " +", "Executes tasks and displays the equivalent command lines.")
  val exportDetailed =
    s"""$ExportCommand [--last] +
	Runs the specified tasks and prints the equivalent command lines or other exportable information for those runs.

	--last
		Uses information from the previous execution

	NOTES: These command lines are necessarily approximate.  Usually tasks do not actually
	execute the command line and the actual command line program may not be installed or
	on the PATH.  Incremental tasks will typically show the command line for an
	incremental run and not for a full run.  Many tasks have no direct command line
	equivalent and will show nothing at all.
"""

  val InspectCommand = "inspect"
  val inspectBrief = (InspectCommand + " [uses|tree|definitions] ", "Prints the value for 'key', the defining scope, delegates, related definitions, and dependencies.")
  val inspectDetailed = s"""
    |$InspectCommand 
    |
    |	For a plain setting, the value bound to the key argument is displayed using its toString method.
    |	Otherwise, the type of task ("Task" or "Input task") is displayed.
    |
    |	"Dependencies" shows the settings that this setting depends on.
    |
    |	"Reverse dependencies" shows the settings that depend on this setting.
    |
    |	When a key is resolved to a value, it may not actually be defined in the requested scope.
    |	In this case, there is a defined search sequence.
    |	"Delegates" shows the scopes that are searched for the key.
    |	"Provided by" shows the scope that contained the value returned for the key.
    |
    |	"Related" shows all of the scopes in which the key is defined.
    |
    |$InspectCommand tree 
    |
    |	Displays `key` and its dependencies in a tree structure.
    |	For settings, the value bound to the setting is displayed and for tasks, the type of the task is shown.
    |
    |$InspectCommand uses 
    |
    |	Displays the settings and tasks that directly depend on `key`.
    |
    |$InspectCommand definitions 
    |
    |	Displays the scopes in which `key` is defined.
    |
    |$InspectCommand actual 
    |
    |	Displays the actual dependencies used by `key`.
    |	This is useful because delegation means that a dependency can come from a scope other than the requested one.
    |	Using `inspect actual` will show exactly which scope is providing a value for a setting.
  """.stripMargin.trim

  val SetCommand = "set"
  val setBrief = (s"$SetCommand [every] ", "Evaluates a Setting and applies it to the current project.")
  val setDetailed =
    SetCommand + """ [every] 

	Applies the given setting to the current project:
	  1) Constructs the expression provided as an argument by compiling and loading it.
	  2) Appends the new setting to the current project's settings.
	  3) Re-evaluates the build's settings.

	This command does not rebuild the build definitions, plugins, or configurations.
	It does not automatically persist the setting(s) either.
	To persist the setting(s), run 'session save' or 'session save-all'.

	If 'every' is specified, the setting is evaluated in the current context
	and the resulting value is used in every scope.  This overrides the value
	bound to the key everywhere.
"""

  def SessionCommand = "session"
  def sessionBrief = (SessionCommand, "Manipulates session settings.  For details, run 'help " + SessionCommand + "'.")

  def settingsPreamble = commonPreamble("settings")
  def tasksPreamble = commonPreamble("tasks") + """
Tasks produce values.  Use the 'show' command to run the task and print the resulting value."""

  def commonPreamble(label: String) = """
This is a list of %s defined for the current project.
It does not list the scopes the %]

%
	Restricts the %+
	Adds the builds at the provided URIs to this session.
	These builds may be selected using the """ + ProjectCommand + """ command.
	Alternatively, tasks from these builds may be run using the explicit syntax {URI}project/task

""" + ProjectsCommand + """ remove +
	Removes extra builds from this session.
	Builds explicitly listed in the build definition are not affected by this command.
"""

  def sbtrc = ".sbtrc"

  def DefaultsCommand = "add-default-commands"
  def DefaultsBrief = (DefaultsCommand, DefaultsDetailed)
  def DefaultsDetailed = "Registers default built-in commands"

  def Load = "load"
  def LoadLabel = "a project"
  def LoadCommand = "load-commands"
  def LoadCommandLabel = "commands"

  def LoadFailed = "load-failed"

  def LoadProjectImpl = "loadp"
  def LoadProject = "reload"
  def LoadProjectBrief = (LoadProject, "(Re)loads the current project or changes to plugins project or returns from it.")
  def LoadProjectDetailed = LoadProject +
    s"""

\t(Re)loads the project in the current directory.

$LoadProject plugins

\t(Re)loads the plugins project (under project directory).

$LoadProject return

\t(Re)loads the root project (and leaves the plugins project)."""

  def InitCommand = "initialize"
  def InitBrief = (InitCommand, "Initializes command processing.")
  def InitDetailed =
    InitCommand + """
	Initializes command processing.

Runs the following commands.

defaults
	Registers default commands.

< ~/.sbtrc
< .sbtrc
	Runs commands from ~/.sbtrc and ./.sbtrc if they exist
"""

  import java.io.File
  import sbt.io.syntax._

  def sbtRCs(s: State): Seq[File] =
    (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.

$SwitchCommand [=] []
	Uses the Scala installation at  by configuring the scalaHome setting for
	all projects.

	If  is specified, it is used as the value of the scalaVersion setting.
	This is important when using managed dependencies.  This version will determine the
	cross-version used as well as transitive dependencies.

	If  is provided, it is then executed.

	See also `help $CrossCommand`
"""
}