From 018ef2b3c79d3cf88dd09179b3f453c1539e165b Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sun, 5 Sep 2010 11:16:53 -0400 Subject: [PATCH] add failure wall command '--' --- main/CommandSupport.scala | 2 ++ main/Main.scala | 6 +++++- main/State.scala | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/main/CommandSupport.scala b/main/CommandSupport.scala index a2308834c..b5bc3a0e5 100644 --- a/main/CommandSupport.scala +++ b/main/CommandSupport.scala @@ -160,6 +160,8 @@ CompileSyntax + """ Compiled classes will be written to the 'classes' directory. Cached information about the compilation will be written to 'cache'. """ + + val FailureWall = "--" def Load = "load" def LoadLabel = "a project" diff --git a/main/Main.scala b/main/Main.scala index 1a3e60f7a..6aee461e5 100644 --- a/main/Main.scala +++ b/main/Main.scala @@ -61,9 +61,13 @@ class xMain extends xsbti.AppMain import CommandSupport._ object Commands { - def DefaultCommands = Seq(help, reload, read, history, exit, load, loadCommands, compile, discover, + def DefaultCommands = Seq(ignore, help, reload, read, history, exit, load, loadCommands, compile, discover, projects, project, setOnFailure, ifLast, multi, shell, alias, append, act) + def ignore = nothing(Set(FailureWall)) + + def nothing(ignore: Set[String]) = Command.univ { s => Apply(){ case in if ignore(in.line) => s } } + def applicable(state: State): Stream[Apply] = state.processors.toStream.flatMap(_.applies(state) ) diff --git a/main/State.scala b/main/State.scala index c6f4d5cec..7360aa2b0 100644 --- a/main/State.scala +++ b/main/State.scala @@ -3,7 +3,8 @@ */ package sbt -import java.io.File + import java.io.File + import CommandSupport.FailureWall case class State(project: Any)( val configuration: xsbti.AppConfiguration, @@ -50,10 +51,18 @@ object State 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 + { + val remaining = s.commands.dropWhile(_ != FailureWall) + if(remaining.isEmpty) { - case Some(c) => s.copy()(commands = c :: Nil, onFailure = None) - case None => exit(ok = false) + s.onFailure match + { + case Some(c) => s.copy()(commands = c :: Nil, onFailure = None) + case None => exit(ok = false) + } } + else + s.copy()(commands = remaining) + } } } \ No newline at end of file