add generic attribute map to State

This commit is contained in:
Mark Harrah 2010-09-05 10:56:24 -04:00
parent fec83c1470
commit cc4fc95dba
2 changed files with 6 additions and 1 deletions

View File

@ -22,7 +22,7 @@ class xMain extends xsbti.AppMain
import CommandSupport.{DefaultsCommand, InitCommand}
val initialCommandDefs = Seq(initialize, defaults)
val commands = DefaultsCommand :: InitCommand :: configuration.arguments.map(_.trim).toList
val state = State( () )( configuration, initialCommandDefs, Set.empty, None, commands, Next.Continue )
val state = State( () )( configuration, initialCommandDefs, Set.empty, None, commands, AttributeMap.empty, Next.Continue )
run(state)
}

View File

@ -11,6 +11,7 @@ case class State(project: Any)(
val exitHooks: Set[ExitHook],
val onFailure: Option[String],
val commands: Seq[String],
val attributes: AttributeMap,
val next: Next.Value
)
@ -24,6 +25,8 @@ trait StateOps {
def fail: State
def ++ (newCommands: Seq[Command]): State
def + (newCommand: Command): State
def get[T](key: AttributeKey[T]): Option[T]
def put[T](key: AttributeKey[T], value: T): State
def baseDir: File
}
object State
@ -44,6 +47,8 @@ object State
def continue = setNext(Next.Continue)
def reload = setNext(Next.Reload)
def exit(ok: Boolean) = setNext(if(ok) Next.Fail else Next.Done)
def get[T](key: AttributeKey[T]) = s.attributes.get(key)
def put[T](key: AttributeKey[T], value: T) = s.copy()(attributes = s.attributes.put(key, value))
def fail =
s.onFailure match
{