diff --git a/main/Main.scala b/main/Main.scala index be3de63a0..af1dae7b9 100644 --- a/main/Main.scala +++ b/main/Main.scala @@ -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) } diff --git a/main/State.scala b/main/State.scala index a153ddea3..c6f4d5cec 100644 --- a/main/State.scala +++ b/main/State.scala @@ -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 {