mirror of https://github.com/sbt/sbt.git
addCommandAlias method for defining command aliases in build definitions. fixes #388
This commit is contained in:
parent
868196e652
commit
6746557d05
|
|
@ -1139,6 +1139,18 @@ trait BuildExtra extends BuildCommon
|
||||||
{
|
{
|
||||||
import Defaults._
|
import Defaults._
|
||||||
|
|
||||||
|
/** Defines an alias given by `name` that expands to `value`.
|
||||||
|
* This alias is defined globally after projects are loaded.
|
||||||
|
* The alias is undefined when projects are unloaded.
|
||||||
|
* Names are restricted to be either alphanumeric or completely symbolic.
|
||||||
|
* As an exception, '-' and '_' are allowed within an alphanumeric name.*/
|
||||||
|
def addCommandAlias(name: String, value: String): Seq[Setting[State => State]] =
|
||||||
|
{
|
||||||
|
val add = (s: State) => BasicCommands.addAlias(s, name, value)
|
||||||
|
val remove = (s: State) => BasicCommands.removeAlias(s, name)
|
||||||
|
def compose(setting: SettingKey[State => State], f: State => State) = setting in Global ~= (_ compose f)
|
||||||
|
Seq( compose(onLoad, add), compose(onUnload, remove) )
|
||||||
|
}
|
||||||
def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
|
def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
|
||||||
libraryDependencies <+= (sbtBinaryVersion in update,scalaBinaryVersion in update) { (sbtV, scalaV) => sbtPluginExtra(dependency, sbtV, scalaV) }
|
libraryDependencies <+= (sbtBinaryVersion in update,scalaBinaryVersion in update) { (sbtV, scalaV) => sbtPluginExtra(dependency, sbtV, scalaV) }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
object A extends App {
|
||||||
|
if(args(0).toBoolean) () else error("Fail")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
addCommandAlias("demo-success", "run true") ++
|
||||||
|
addCommandAlias("demo-failure", "run false")
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
> demo-success
|
||||||
|
-> demo-failure
|
||||||
Loading…
Reference in New Issue