From 109326d34b67920552c9662a5c34ca6daa2e5a30 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sun, 24 Jul 2011 17:36:42 -0400 Subject: [PATCH] additional warning when ignoring project load failure --- main/Main.scala | 4 ++++ main/Project.scala | 1 + main/State.scala | 2 ++ 3 files changed, 7 insertions(+) diff --git a/main/Main.scala b/main/Main.scala index ad5642d90..58ade89e1 100644 --- a/main/Main.scala +++ b/main/Main.scala @@ -354,7 +354,11 @@ object BuiltinCommands else if(matches(Quit)) s.exit(ok = false) else if(matches("ignore")) + { + val hadPrevious = Project.isProjectLoaded(s) + logger(s).warn("Ignoring load failure: " + (if(hadPrevious) "using previously loaded project." else "no project loaded.")) s + } else { println("Invalid response.") diff --git a/main/Project.scala b/main/Project.scala index 77b865c9b..000878842 100644 --- a/main/Project.scala +++ b/main/Project.scala @@ -129,6 +129,7 @@ object Project extends Init[Scope] with ProjectExtra def getOrError[T](state: State, key: AttributeKey[T], msg: String): T = state get key getOrElse error(msg) def structure(state: State): BuildStructure = getOrError(state, stateBuildStructure, "No build loaded.") def session(state: State): SessionSettings = getOrError(state, sessionSettings, "Session not initialized.") + def isProjectLoaded(state: State): Boolean = (state has sessionSettings) && (state has stateBuildStructure) def extract(state: State): Extracted = extract( session(state), structure(state) ) def extract(se: SessionSettings, st: BuildStructure): Extracted = Extracted(st, se, se.current) diff --git a/main/State.scala b/main/State.scala index 5b60fb52f..7ea7bcdfe 100644 --- a/main/State.scala +++ b/main/State.scala @@ -40,6 +40,7 @@ trait StateOps { def get[T](key: AttributeKey[T]): Option[T] def put[T](key: AttributeKey[T], value: T): State def remove(key: AttributeKey[_]): State + def has(key: AttributeKey[_]): Boolean def baseDir: File def locked[T](file: File)(t: => T): T def runExitHooks(): State @@ -72,6 +73,7 @@ object State def exit(ok: Boolean) = setResult(Some(Exit(if(ok) 0 else 1))) 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 has(key: AttributeKey[_]) = s.attributes contains key def remove(key: AttributeKey[_]) = s.copy(attributes = s.attributes remove key) def fail = {