mirror of https://github.com/sbt/sbt.git
Deprecate -, --, and --- in favor of onFailure, sbtClearOnFailure, and resumeFromFailure.
This commit is contained in:
parent
4e7f30c893
commit
86ae3c8c59
|
|
@ -113,8 +113,23 @@ AliasCommand + """ name=
|
||||||
def StashOnFailure = "sbtStashOnFailure"
|
def StashOnFailure = "sbtStashOnFailure"
|
||||||
def PopOnFailure = "sbtPopOnFailure"
|
def PopOnFailure = "sbtPopOnFailure"
|
||||||
|
|
||||||
def ClearOnFailure = "--"
|
// commands with poor choices for names since they clash with the usual conventions for command line options
|
||||||
def OnFailure = "-"
|
// 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 =
|
def OnFailureDetailed =
|
||||||
OnFailure + """ command
|
OnFailure + """ command
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package sbt
|
||||||
import Types.{const,idFun}
|
import Types.{const,idFun}
|
||||||
import Function.tupled
|
import Function.tupled
|
||||||
import Command.applyEffect
|
import Command.applyEffect
|
||||||
import State.FailureWall
|
|
||||||
import HistoryCommands.{Start => HistoryPrefix}
|
import HistoryCommands.{Start => HistoryPrefix}
|
||||||
import BasicCommandStrings._
|
import BasicCommandStrings._
|
||||||
import CommandUtil._
|
import CommandUtil._
|
||||||
|
|
@ -16,7 +15,7 @@ package sbt
|
||||||
|
|
||||||
object BasicCommands
|
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 nop = Command.custom(s => success(() => s))
|
||||||
def ignore = Command.command(FailureWall)(idFun)
|
def ignore = Command.command(FailureWall)(idFun)
|
||||||
|
|
@ -52,7 +51,7 @@ object BasicCommands
|
||||||
|
|
||||||
def multi = Command.custom(multiApplied, Help(Multi, MultiBrief, MultiDetailed) )
|
def multi = Command.custom(multiApplied, Help(Multi, MultiBrief, MultiDetailed) )
|
||||||
|
|
||||||
lazy val otherCommandParser = (s: State) => token(OptSpace ~> combinedLax(s, any.+) )
|
lazy val otherCommandParser = (s: State) => token(OptSpace ~> combinedLax(s, NotSpaceClass ~ any.*) )
|
||||||
def combinedLax(s: State, any: Parser[_]): Parser[String] =
|
def combinedLax(s: State, any: Parser[_]): Parser[String] =
|
||||||
matched(s.combinedParser | token(any, hide= const(true)))
|
matched(s.combinedParser | token(any, hide= const(true)))
|
||||||
|
|
||||||
|
|
@ -66,6 +65,21 @@ object BasicCommands
|
||||||
def setOnFailure = Command(OnFailure, Help.more(OnFailure, OnFailureDetailed))(otherCommandParser) { (s, arg) =>
|
def setOnFailure = Command(OnFailure, Help.more(OnFailure, OnFailureDetailed))(otherCommandParser) { (s, arg) =>
|
||||||
s.copy(onFailure = Some(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 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 stashOnFailure = Command.command(StashOnFailure)(s => s.copy(onFailure = None).update(OnFailureStack)(s.onFailure :: _.toList.flatten))
|
||||||
def popOnFailure = Command.command(PopOnFailure) { s =>
|
def popOnFailure = Command.command(PopOnFailure) { s =>
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ trait StateOps {
|
||||||
object State
|
object State
|
||||||
{
|
{
|
||||||
/** Indicates where command execution should resume after a failure.*/
|
/** Indicates where command execution should resume after a failure.*/
|
||||||
final val FailureWall = "---"
|
val FailureWall = BasicCommandStrings.FailureWall
|
||||||
|
|
||||||
/** Represents the next action for the command processor.*/
|
/** Represents the next action for the command processor.*/
|
||||||
sealed trait Next
|
sealed trait Next
|
||||||
|
|
@ -199,7 +199,8 @@ object State
|
||||||
def handleError(t: Throwable): State = handleException(t, s, log)
|
def handleError(t: Throwable): State = handleException(t, s, log)
|
||||||
def fail =
|
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)
|
if(remaining.isEmpty)
|
||||||
applyOnFailure(s, Nil, exit(ok = false))
|
applyOnFailure(s, Nil, exit(ok = false))
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,8 @@ object BuiltinCommands
|
||||||
def DefaultCommands: Seq[Command] = Seq(ignore, help, about, tasks, settingsCommand, loadProject,
|
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,
|
projects, project, reboot, read, history, set, sessionCommand, inspect, loadProjectImpl, loadFailed, Cross.crossBuild, Cross.switchVersion,
|
||||||
setOnFailure, clearOnFailure, stashOnFailure, popOnFailure,
|
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 DefaultBootCommands: Seq[String] = LoadProject :: (IfLast + " " + Shell) :: Nil
|
||||||
|
|
||||||
def boot = Command.make(BootCommand)(bootParser)
|
def boot = Command.make(BootCommand)(bootParser)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue