mirror of https://github.com/sbt/sbt.git
add generic attribute map to State
This commit is contained in:
parent
fec83c1470
commit
cc4fc95dba
|
|
@ -22,7 +22,7 @@ class xMain extends xsbti.AppMain
|
||||||
import CommandSupport.{DefaultsCommand, InitCommand}
|
import CommandSupport.{DefaultsCommand, InitCommand}
|
||||||
val initialCommandDefs = Seq(initialize, defaults)
|
val initialCommandDefs = Seq(initialize, defaults)
|
||||||
val commands = DefaultsCommand :: InitCommand :: configuration.arguments.map(_.trim).toList
|
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)
|
run(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ case class State(project: Any)(
|
||||||
val exitHooks: Set[ExitHook],
|
val exitHooks: Set[ExitHook],
|
||||||
val onFailure: Option[String],
|
val onFailure: Option[String],
|
||||||
val commands: Seq[String],
|
val commands: Seq[String],
|
||||||
|
val attributes: AttributeMap,
|
||||||
val next: Next.Value
|
val next: Next.Value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -24,6 +25,8 @@ trait StateOps {
|
||||||
def fail: State
|
def fail: State
|
||||||
def ++ (newCommands: Seq[Command]): State
|
def ++ (newCommands: Seq[Command]): State
|
||||||
def + (newCommand: 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
|
def baseDir: File
|
||||||
}
|
}
|
||||||
object State
|
object State
|
||||||
|
|
@ -44,6 +47,8 @@ object State
|
||||||
def continue = setNext(Next.Continue)
|
def continue = setNext(Next.Continue)
|
||||||
def reload = setNext(Next.Reload)
|
def reload = setNext(Next.Reload)
|
||||||
def exit(ok: Boolean) = setNext(if(ok) Next.Fail else Next.Done)
|
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 =
|
def fail =
|
||||||
s.onFailure match
|
s.onFailure match
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue