Deprecate -, --, and --- in favor of onFailure, sbtClearOnFailure, and resumeFromFailure.

This commit is contained in:
Mark Harrah 2013-10-24 16:34:16 -04:00
parent 4e7f30c893
commit 86ae3c8c59
4 changed files with 49 additions and 18 deletions

View File

@ -53,7 +53,7 @@ ReadCommand + ReadFiles + """
You probably need to escape this command if entering it at your shell."""
def ApplyCommand = "apply"
def ApplyDetailed =
def ApplyDetailed =
ApplyCommand + """ [-cp|-classpath <classpath>] <module-name>*
Transforms the current State by calling <module-name>.apply(currentState) for each listed module name.
Here, currentState is of type sbt.State.
@ -113,8 +113,23 @@ AliasCommand + """ name=
def StashOnFailure = "sbtStashOnFailure"
def PopOnFailure = "sbtPopOnFailure"
def ClearOnFailure = "--"
def OnFailure = "-"
// commands with poor choices for names since they clash with the usual conventions for command line options
// these are not documented and are mainly internal commands and can be removed without a full deprecation cycle
object Compat {
def OnFailure = "-"
def ClearOnFailure = "--"
def FailureWall = "---"
def OnFailureDeprecated = deprecatedAlias(OnFailure, BasicCommandStrings.OnFailure)
def ClearOnFailureDeprecated = deprecatedAlias(ClearOnFailure, BasicCommandStrings.ClearOnFailure)
def FailureWallDeprecated = deprecatedAlias(FailureWall, BasicCommandStrings.FailureWall)
private[this] def deprecatedAlias(oldName: String, newName: String): String =
s"The `$oldName` command is deprecated in favor of `$newName` and will be removed in 0.14.0"
}
def FailureWall = "resumeFromFailure"
def ClearOnFailure = "sbtClearOnFailure"
def OnFailure = "onFailure"
def OnFailureDetailed =
OnFailure + """ command

View File

@ -6,7 +6,6 @@ package sbt
import Types.{const,idFun}
import Function.tupled
import Command.applyEffect
import State.FailureWall
import HistoryCommands.{Start => HistoryPrefix}
import BasicCommandStrings._
import CommandUtil._
@ -16,7 +15,7 @@ package sbt
object BasicCommands
{
lazy val allBasicCommands = Seq(nop, ignore, help, multi, ifLast, append, setOnFailure, clearOnFailure, stashOnFailure, popOnFailure, reboot, call, exit, continuous, history, shell, read, alias)
lazy val allBasicCommands = Seq(nop, ignore, help, multi, ifLast, append, setOnFailure, clearOnFailure, stashOnFailure, popOnFailure, reboot, call, exit, continuous, history, shell, read, alias) ++ compatCommands
def nop = Command.custom(s => success(() => s))
def ignore = Command.command(FailureWall)(idFun)
@ -47,13 +46,13 @@ object BasicCommands
( token(';' ~> OptSpace) flatMap { _ => matched((s.combinedParser&nonSemi) | nonSemi) <~ token(OptSpace) } map (_.trim) ).+
}
def multiApplied(s: State) =
def multiApplied(s: State) =
Command.applyEffect( multiParser(s) )( _ ::: s )
def multi = Command.custom(multiApplied, Help(Multi, MultiBrief, MultiDetailed) )
lazy val otherCommandParser = (s: State) => token(OptSpace ~> combinedLax(s, any.+) )
def combinedLax(s: State, any: Parser[_]): Parser[String] =
lazy val otherCommandParser = (s: State) => token(OptSpace ~> combinedLax(s, NotSpaceClass ~ any.*) )
def combinedLax(s: State, any: Parser[_]): Parser[String] =
matched(s.combinedParser | token(any, hide= const(true)))
def ifLast = Command(IfLast, Help.more(IfLast, IfLastDetailed))(otherCommandParser) { (s, arg) =>
@ -62,10 +61,25 @@ object BasicCommands
def append = Command(AppendCommand, Help.more(AppendCommand, AppendLastDetailed))(otherCommandParser) { (s, arg) =>
s.copy(remainingCommands = s.remainingCommands :+ arg)
}
def setOnFailure = Command(OnFailure, Help.more(OnFailure, OnFailureDetailed))(otherCommandParser) { (s, arg) =>
s.copy(onFailure = Some(arg))
}
private[sbt] def compatCommands = Seq(
Command.command(Compat.ClearOnFailure) { s =>
s.log.warn(Compat.ClearOnFailureDeprecated)
s.copy(onFailure = None)
},
Command.arb(s => token(Compat.OnFailure, hide = const(true)).flatMap(x => otherCommandParser(s)) ){ (s, arg) =>
s.log.warn(Compat.OnFailureDeprecated)
s.copy(onFailure = Some(arg))
},
Command.command(Compat.FailureWall) { s =>
s.log.warn(Compat.FailureWallDeprecated)
s
}
)
def clearOnFailure = Command.command(ClearOnFailure)(s => s.copy(onFailure = None))
def stashOnFailure = Command.command(StashOnFailure)(s => s.copy(onFailure = None).update(OnFailureStack)(s.onFailure :: _.toList.flatten))
def popOnFailure = Command.command(PopOnFailure) { s =>
@ -207,7 +221,7 @@ object BasicCommands
def removeAliases(s: State): State = removeTagged(s, CommandAliasKey)
def removeAlias(s: State, name: String): State = s.copy(definedCommands = s.definedCommands.filter(c => !isAliasNamed(name, c)) )
def removeTagged(s: State, tag: AttributeKey[_]): State = s.copy(definedCommands = removeTagged(s.definedCommands, tag))
def removeTagged(as: Seq[Command], tag: AttributeKey[_]): Seq[Command] = as.filter(c => ! (c.tags contains tag))
@ -237,5 +251,5 @@ object BasicCommands
case Some((n,v)) => aliasBody(n,v)(state)
}
val CommandAliasKey = AttributeKey[(String,String)]("is-command-alias", "Internal: marker for Commands created as aliases for another command.")
val CommandAliasKey = AttributeKey[(String,String)]("is-command-alias", "Internal: marker for Commands created as aliases for another command.")
}

View File

@ -130,7 +130,7 @@ trait StateOps {
object State
{
/** Indicates where command execution should resume after a failure.*/
final val FailureWall = "---"
val FailureWall = BasicCommandStrings.FailureWall
/** Represents the next action for the command processor.*/
sealed trait Next
@ -199,7 +199,8 @@ object State
def handleError(t: Throwable): State = handleException(t, s, log)
def fail =
{
val remaining = s.remainingCommands.dropWhile(_ != FailureWall)
import BasicCommandStrings.Compat.{FailureWall => CompatFailureWall}
val remaining = s.remainingCommands.dropWhile(c => c != FailureWall && c != CompatFailureWall)
if(remaining.isEmpty)
applyOnFailure(s, Nil, exit(ok = false))
else

View File

@ -60,7 +60,7 @@ object StandardMain
val console = ConsoleOut.systemOutOverwrite(ConsoleOut.overwriteContaining("Resolving "))
def initialGlobalLogging: GlobalLogging = GlobalLogging.initial(MainLogging.globalDefault(console), File.createTempFile("sbt",".log"), console)
def initialState(configuration: xsbti.AppConfiguration, initialDefinitions: Seq[Command], preCommands: Seq[String]): State =
{
val commands = preCommands ++ configuration.arguments.map(_.trim)
@ -85,7 +85,8 @@ object BuiltinCommands
def DefaultCommands: Seq[Command] = Seq(ignore, help, about, tasks, settingsCommand, loadProject,
projects, project, reboot, read, history, set, sessionCommand, inspect, loadProjectImpl, loadFailed, Cross.crossBuild, Cross.switchVersion,
setOnFailure, clearOnFailure, stashOnFailure, popOnFailure,
ifLast, multi, shell, continuous, eval, alias, append, last, lastGrep, export, boot, nop, call, exit, act)
ifLast, multi, shell, continuous, eval, alias, append, last, lastGrep, export, boot, nop, call, exit, act) ++
compatCommands
def DefaultBootCommands: Seq[String] = LoadProject :: (IfLast + " " + Shell) :: Nil
def boot = Command.make(BootCommand)(bootParser)
@ -245,7 +246,7 @@ object BuiltinCommands
s.log.info(Inspect.output(s, option, sk))
s
}
@deprecated("Use Inspect.output", "0.13.0")
def inspectOutput(s: State, option: Inspect.Mode, sk: Def.ScopedKey[_]): String = Inspect.output(s, option, sk)
@ -322,7 +323,7 @@ object BuiltinCommands
val (str, ref, display) = extractLast(s)
Output.last(sks, str.streams(s), printLast(s), sid)(display)
keepLastLog(s)
}
}
/** Determines the log file that last* commands should operate on. See also isLastOnly. */
def lastLogFile(s: State) =