From fbe8630433609b0c03cfbd5fabe9a55e44ceb9d8 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 16 Dec 2011 08:21:54 -0500 Subject: [PATCH] move calls to runExitHooks into the State.{reload,exit,reboot} commands. fixes #306 --- main/Main.scala | 6 ++---- main/State.scala | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/main/Main.scala b/main/Main.scala index 941bc90db..a81032304 100644 --- a/main/Main.scala +++ b/main/Main.scala @@ -295,7 +295,7 @@ object BuiltinCommands def clearOnFailure = Command.command(ClearOnFailure)(s => s.copy(onFailure = None)) def reboot = Command(RebootCommand, RebootBrief, RebootDetailed)(rebootParser) { (s, full) => - s.runExitHooks().reboot(full) + s.reboot(full) } def rebootParser(s: State) = token(Space ~> "full" ^^^ true) ?? false @@ -533,9 +533,7 @@ object BuiltinCommands def project = Command.make(ProjectCommand, projectBrief, projectDetailed)(ProjectNavigation.command) - def exit = Command.command(TerminateAction, exitBrief, exitBrief ) ( doExit ) - - def doExit(s: State): State = s.runExitHooks().exit(true) + def exit = Command.command(TerminateAction, exitBrief, exitBrief ) ( _ exit true ) def loadFailed = Command.command(LoadFailed)(handleLoadFailed) @tailrec def handleLoadFailed(s: State): State = diff --git a/main/State.scala b/main/State.scala index 4823d6dba..05cea6202 100644 --- a/main/State.scala +++ b/main/State.scala @@ -163,11 +163,11 @@ object State def setNext(n: Next) = s.copy(next = n) def setResult(ro: Option[xsbti.MainResult]) = ro match { case None => continue; case Some(r) => setNext(new Return(r)) } def continue = setNext(Continue) - def reboot(full: Boolean) = throw new xsbti.FullReload(s.remainingCommands.toArray, full) - def reload = setNext(new Return(defaultReload(s))) + def reboot(full: Boolean) ={ runExitHooks(); throw new xsbti.FullReload(s.remainingCommands.toArray, full) } + def reload = runExitHooks().setNext(new Return(defaultReload(s))) def clearGlobalLog = setNext(ClearGlobalLog) def keepLastLog = setNext(KeepLastLog) - def exit(ok: Boolean) = setNext(new Return(Exit(if(ok) 0 else 1))) + def exit(ok: Boolean) = runExitHooks().setNext(new Return(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 update[T](key: AttributeKey[T])(f: Option[T] => T): State = put(key, f(get(key)))