mirror of https://github.com/sbt/sbt.git
move applyEffect to Command
This commit is contained in:
parent
784d83af17
commit
2d394c7551
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
Loading…
Reference in New Issue