move applyEffect to Command

This commit is contained in:
Mark Harrah 2011-01-22 15:07:59 -05:00
parent 784d83af17
commit 2d394c7551
3 changed files with 6 additions and 5 deletions

View File

@ -56,7 +56,10 @@ object Command
def validID(name: String) =
Parser(OpOrID)(name).resultEmpty.isDefined
def applyEffect[T](p: Parser[T])(f: T => State): Parser[() => State] =
p map { t => () => f(t) }
def combine(cmds: Seq[Command]): State => Parser[() => State] =
{
val (simple, arbs) = separateCommands(cmds)

View File

@ -10,7 +10,7 @@ package sbt
import sbt.build.{AggressiveCompile, Auto, BuildException, LoadCommand, Parse, ParseException, ProjectLoad, SourceLoad}
import sbt.complete.{DefaultParsers, Parser}
import Command.{Analysis,HistoryPath,Logged,Watch}
import Command.{applyEffect,Analysis,HistoryPath,Logged,Watch}
import scala.annotation.tailrec
import scala.collection.JavaConversions._
import Function.tupled
@ -85,8 +85,6 @@ object Commands
val base = (OptSpace ~> (name ~ assign.?).?)
applyEffect(base)(t => runAlias(s, t) )
}
def applyEffect[T](p: Parser[T])(f: T => State): Parser[() => State] =
p map { t => () => f(t) }
def runAlias(s: State, args: Option[(String, Option[String])]): State =
args match
{

View File

@ -73,5 +73,5 @@ final class ProjectNavigation(s: State)
val projectP = token(ID map (id => new ChangeProject(id)) examples projects.toSet )
success(ShowCurrent) | ( token(Space) ~> (token('/' ^^^ Root) | buildP | projectP) )
}
val command: Parser[() => State] = Commands.applyEffect(parser)(apply)
val command: Parser[() => State] = Command.applyEffect(parser)(apply)
}