mirror of https://github.com/sbt/sbt.git
rank settings, tasks and use this to restrict help/settings/tasks output. fixes #315
This commit is contained in:
parent
c7c4969eb7
commit
94b4a3784a
|
|
@ -15,6 +15,7 @@ sealed trait AttributeKey[T] {
|
||||||
def description: Option[String]
|
def description: Option[String]
|
||||||
def extend: Seq[AttributeKey[_]]
|
def extend: Seq[AttributeKey[_]]
|
||||||
def isLocal: Boolean
|
def isLocal: Boolean
|
||||||
|
def rank: Int
|
||||||
}
|
}
|
||||||
private[sbt] abstract class SharedAttributeKey[T] extends AttributeKey[T] {
|
private[sbt] abstract class SharedAttributeKey[T] extends AttributeKey[T] {
|
||||||
override final def toString = label
|
override final def toString = label
|
||||||
|
|
@ -27,23 +28,30 @@ private[sbt] abstract class SharedAttributeKey[T] extends AttributeKey[T] {
|
||||||
}
|
}
|
||||||
object AttributeKey
|
object AttributeKey
|
||||||
{
|
{
|
||||||
def apply[T](name: String)(implicit mf: Manifest[T]): AttributeKey[T] = new SharedAttributeKey[T] {
|
def apply[T](name: String)(implicit mf: Manifest[T]): AttributeKey[T] =
|
||||||
|
make(name, None, Nil, Int.MaxValue)
|
||||||
|
|
||||||
|
def apply[T](name: String, rank: Int)(implicit mf: Manifest[T]): AttributeKey[T] =
|
||||||
|
make(name, None, Nil, rank)
|
||||||
|
|
||||||
|
def apply[T](name: String, description: String)(implicit mf: Manifest[T]): AttributeKey[T] =
|
||||||
|
apply(name, description, Nil)
|
||||||
|
|
||||||
|
def apply[T](name: String, description: String, rank: Int)(implicit mf: Manifest[T]): AttributeKey[T] =
|
||||||
|
apply(name, description, Nil, rank)
|
||||||
|
|
||||||
|
def apply[T](name: String, description: String, extend: Seq[AttributeKey[_]])(implicit mf: Manifest[T]): AttributeKey[T] =
|
||||||
|
apply(name, description, extend, Int.MaxValue)
|
||||||
|
|
||||||
|
def apply[T](name: String, description: String, extend: Seq[AttributeKey[_]], rank: Int)(implicit mf: Manifest[T]): AttributeKey[T] =
|
||||||
|
make(name, Some(description), extend, rank)
|
||||||
|
|
||||||
|
private[this] def make[T](name: String, description0: Option[String], extend0: Seq[AttributeKey[_]], rank0: Int)(implicit mf: Manifest[T]): AttributeKey[T] = new SharedAttributeKey[T] {
|
||||||
def manifest = mf
|
def manifest = mf
|
||||||
def label = name
|
def label = name
|
||||||
def description = None
|
def description = description0
|
||||||
def extend = Nil
|
|
||||||
}
|
|
||||||
def apply[T](name: String, description0: String)(implicit mf: Manifest[T]): AttributeKey[T] = new SharedAttributeKey[T] {
|
|
||||||
def manifest = mf
|
|
||||||
def label = name
|
|
||||||
def description = Some(description0)
|
|
||||||
def extend = Nil
|
|
||||||
}
|
|
||||||
def apply[T](name: String, description0: String, extend0: Seq[AttributeKey[_]])(implicit mf: Manifest[T]): AttributeKey[T] = new SharedAttributeKey[T] {
|
|
||||||
def manifest = mf
|
|
||||||
def label = name
|
|
||||||
def description = Some(description0)
|
|
||||||
def extend = extend0
|
def extend = extend0
|
||||||
|
def rank = rank0
|
||||||
}
|
}
|
||||||
private[sbt] def local[T](implicit mf: Manifest[T]): AttributeKey[T] = new AttributeKey[T] {
|
private[sbt] def local[T](implicit mf: Manifest[T]): AttributeKey[T] = new AttributeKey[T] {
|
||||||
def manifest = mf
|
def manifest = mf
|
||||||
|
|
@ -52,6 +60,7 @@ object AttributeKey
|
||||||
def extend = Nil
|
def extend = Nil
|
||||||
override def toString = label
|
override def toString = label
|
||||||
def isLocal: Boolean = true
|
def isLocal: Boolean = true
|
||||||
|
def rank = Int.MaxValue
|
||||||
}
|
}
|
||||||
private[sbt] final val LocalLabel = "$local"
|
private[sbt] final val LocalLabel = "$local"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue