mirror of https://github.com/sbt/sbt.git
move applyEffect to Command
This commit is contained in:
parent
784d83af17
commit
2d394c7551
|
|
@ -57,6 +57,9 @@ object Command
|
||||||
def validID(name: String) =
|
def validID(name: String) =
|
||||||
Parser(OpOrID)(name).resultEmpty.isDefined
|
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] =
|
def combine(cmds: Seq[Command]): State => Parser[() => State] =
|
||||||
{
|
{
|
||||||
val (simple, arbs) = separateCommands(cmds)
|
val (simple, arbs) = separateCommands(cmds)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ package sbt
|
||||||
import sbt.build.{AggressiveCompile, Auto, BuildException, LoadCommand, Parse, ParseException, ProjectLoad, SourceLoad}
|
import sbt.build.{AggressiveCompile, Auto, BuildException, LoadCommand, Parse, ParseException, ProjectLoad, SourceLoad}
|
||||||
import sbt.complete.{DefaultParsers, Parser}
|
import sbt.complete.{DefaultParsers, Parser}
|
||||||
|
|
||||||
import Command.{Analysis,HistoryPath,Logged,Watch}
|
import Command.{applyEffect,Analysis,HistoryPath,Logged,Watch}
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.JavaConversions._
|
import scala.collection.JavaConversions._
|
||||||
import Function.tupled
|
import Function.tupled
|
||||||
|
|
@ -85,8 +85,6 @@ object Commands
|
||||||
val base = (OptSpace ~> (name ~ assign.?).?)
|
val base = (OptSpace ~> (name ~ assign.?).?)
|
||||||
applyEffect(base)(t => runAlias(s, t) )
|
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 =
|
def runAlias(s: State, args: Option[(String, Option[String])]): State =
|
||||||
args match
|
args match
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,5 +73,5 @@ final class ProjectNavigation(s: State)
|
||||||
val projectP = token(ID map (id => new ChangeProject(id)) examples projects.toSet )
|
val projectP = token(ID map (id => new ChangeProject(id)) examples projects.toSet )
|
||||||
success(ShowCurrent) | ( token(Space) ~> (token('/' ^^^ Root) | buildP | projectP) )
|
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