mirror of https://github.com/sbt/sbt.git
minor updates for p2
This commit is contained in:
parent
62691e6681
commit
0c59e9d5a6
|
|
@ -97,7 +97,7 @@ trait TaskSetup
|
||||||
final case class Input(line: String, cursor: Option[Int])
|
final case class Input(line: String, cursor: Option[Int])
|
||||||
{
|
{
|
||||||
lazy val (name, arguments) = line match { case Input.NameRegex(n, a) => (n, a); case _ => (line, "") }
|
lazy val (name, arguments) = line match { case Input.NameRegex(n, a) => (n, a); case _ => (line, "") }
|
||||||
lazy val splitSpace = (arguments split """\s+""").toSeq
|
lazy val splitArgs = (arguments split """\s+""").toSeq
|
||||||
}
|
}
|
||||||
object Input
|
object Input
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ object Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
def read = Command.simple(ReadCommand, ReadBrief, ReadDetailed) { (in, s) =>
|
def read = Command.simple(ReadCommand, ReadBrief, ReadDetailed) { (in, s) =>
|
||||||
val from = in.splitSpace map { p => new File(s.baseDir, p) }
|
val from = in.splitArgs map { p => new File(s.baseDir, p) }
|
||||||
val notFound = notReadable(from)
|
val notFound = notReadable(from)
|
||||||
if(notFound.isEmpty)
|
if(notFound.isEmpty)
|
||||||
readLines(from) ::: s // this means that all commands from all files are loaded, parsed, and inserted before any are executed
|
readLines(from) ::: s // this means that all commands from all files are loaded, parsed, and inserted before any are executed
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ import scala.collection.{mutable, JavaConversions}
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
trait SingleProject extends Tasked
|
trait SingleProject extends Tasked with PrintTask with TaskExtra with Types
|
||||||
{
|
{
|
||||||
def base: File
|
def base = new File(".")
|
||||||
def streamBase = base / "streams"
|
def streamBase = base / "streams"
|
||||||
|
|
||||||
implicit def streams = Dummy.Streams
|
implicit def streams = Dummy.Streams
|
||||||
|
|
@ -44,6 +44,22 @@ object Dummy
|
||||||
val Streams = dummy[TaskStreams](StreamsName)
|
val Streams = dummy[TaskStreams](StreamsName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait PrintTask
|
||||||
|
{
|
||||||
|
def input: Task[Input]
|
||||||
|
lazy val show = input flatMap { in =>
|
||||||
|
val m = ReflectUtilities.allVals[Task[_]](this)
|
||||||
|
val taskStrings = in.splitArgs map { name =>
|
||||||
|
m(name).merge.map {
|
||||||
|
case Seq() => "No result for " + name
|
||||||
|
case Seq( (conf, v) ) => name + ": " + v.toString
|
||||||
|
case confs => confs map { case (conf, v) => conf + ": " + v } mkString(name + ":\n\t", "\n\t", "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taskStrings.join.map { _ foreach println }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object ReflectiveContext
|
object ReflectiveContext
|
||||||
{
|
{
|
||||||
import Transform.Context
|
import Transform.Context
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,19 @@ package sbt
|
||||||
|
|
||||||
/** Result of completely evaluating a task.*/
|
/** Result of completely evaluating a task.*/
|
||||||
sealed trait Result[+T]
|
sealed trait Result[+T]
|
||||||
|
{
|
||||||
|
def toEither: Either[Incomplete, T]
|
||||||
|
}
|
||||||
/** Indicates the task did not complete normally and so it does not have a value.*/
|
/** Indicates the task did not complete normally and so it does not have a value.*/
|
||||||
final case class Inc(cause: Incomplete) extends Result[Nothing]
|
final case class Inc(cause: Incomplete) extends Result[Nothing]
|
||||||
|
{
|
||||||
|
def toEither: Either[Incomplete, Nothing] = Left(cause)
|
||||||
|
}
|
||||||
/** Indicates the task completed normally and produced the given `value`.*/
|
/** Indicates the task completed normally and produced the given `value`.*/
|
||||||
final case class Value[+T](value: T) extends Result[T]
|
final case class Value[+T](value: T) extends Result[T]
|
||||||
|
{
|
||||||
|
def toEither: Either[Incomplete, T] = Right(value)
|
||||||
|
}
|
||||||
|
|
||||||
object Result
|
object Result
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,16 @@
|
||||||
*/
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
object Types extends TypeFunctions
|
object Types extends Types
|
||||||
{
|
{
|
||||||
val :^: = KCons
|
|
||||||
val :+: = HCons
|
|
||||||
type :+:[H, T <: HList] = HCons[H,T]
|
|
||||||
|
|
||||||
implicit def hconsToK[M[_], H, T <: HList](h: M[H] :+: T)(implicit mt: T => KList[M, T]): KList[M, H :+: T] =
|
implicit def hconsToK[M[_], H, T <: HList](h: M[H] :+: T)(implicit mt: T => KList[M, T]): KList[M, H :+: T] =
|
||||||
KCons[H, T, M](h.head, mt(h.tail) )
|
KCons[H, T, M](h.head, mt(h.tail) )
|
||||||
implicit def hnilToK(hnil: HNil): KNil = KNil
|
implicit def hnilToK(hnil: HNil): KNil = KNil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait Types extends TypeFunctions
|
||||||
|
{
|
||||||
|
val :^: = KCons
|
||||||
|
val :+: = HCons
|
||||||
|
type :+:[H, T <: HList] = HCons[H,T]
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue