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
|
|
@ -53,7 +53,7 @@ ReadCommand + ReadFiles + """
|
||||||
You probably need to escape this command if entering it at your shell."""
|
You probably need to escape this command if entering it at your shell."""
|
||||||
|
|
||||||
def ApplyCommand = "apply"
|
def ApplyCommand = "apply"
|
||||||
def ApplyDetailed =
|
def ApplyDetailed =
|
||||||
ApplyCommand + """ [-cp|-classpath <classpath>] <module-name>*
|
ApplyCommand + """ [-cp|-classpath <classpath>] <module-name>*
|
||||||
Transforms the current State by calling <module-name>.apply(currentState) for each listed module name.
|
Transforms the current State by calling <module-name>.apply(currentState) for each listed module name.
|
||||||
Here, currentState is of type sbt.State.
|
Here, currentState is of type sbt.State.
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -47,13 +46,13 @@ object BasicCommands
|
||||||
( token(';' ~> OptSpace) flatMap { _ => matched((s.combinedParser&nonSemi) | nonSemi) <~ token(OptSpace) } map (_.trim) ).+
|
( 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 )
|
Command.applyEffect( multiParser(s) )( _ ::: s )
|
||||||
|
|
||||||
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)))
|
||||||
|
|
||||||
def ifLast = Command(IfLast, Help.more(IfLast, IfLastDetailed))(otherCommandParser) { (s, arg) =>
|
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) =>
|
def append = Command(AppendCommand, Help.more(AppendCommand, AppendLastDetailed))(otherCommandParser) { (s, arg) =>
|
||||||
s.copy(remainingCommands = s.remainingCommands :+ arg)
|
s.copy(remainingCommands = s.remainingCommands :+ arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 =>
|
||||||
|
|
@ -207,7 +221,7 @@ object BasicCommands
|
||||||
|
|
||||||
def removeAliases(s: State): State = removeTagged(s, CommandAliasKey)
|
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 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(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))
|
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)
|
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.")
|
||||||
}
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ object StandardMain
|
||||||
val console = ConsoleOut.systemOutOverwrite(ConsoleOut.overwriteContaining("Resolving "))
|
val console = ConsoleOut.systemOutOverwrite(ConsoleOut.overwriteContaining("Resolving "))
|
||||||
|
|
||||||
def initialGlobalLogging: GlobalLogging = GlobalLogging.initial(MainLogging.globalDefault(console), File.createTempFile("sbt",".log"), console)
|
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 =
|
def initialState(configuration: xsbti.AppConfiguration, initialDefinitions: Seq[Command], preCommands: Seq[String]): State =
|
||||||
{
|
{
|
||||||
val commands = preCommands ++ configuration.arguments.map(_.trim)
|
val commands = preCommands ++ configuration.arguments.map(_.trim)
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -245,7 +246,7 @@ object BuiltinCommands
|
||||||
s.log.info(Inspect.output(s, option, sk))
|
s.log.info(Inspect.output(s, option, sk))
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
@deprecated("Use Inspect.output", "0.13.0")
|
@deprecated("Use Inspect.output", "0.13.0")
|
||||||
def inspectOutput(s: State, option: Inspect.Mode, sk: Def.ScopedKey[_]): String = Inspect.output(s, option, sk)
|
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)
|
val (str, ref, display) = extractLast(s)
|
||||||
Output.last(sks, str.streams(s), printLast(s), sid)(display)
|
Output.last(sks, str.streams(s), printLast(s), sid)(display)
|
||||||
keepLastLog(s)
|
keepLastLog(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determines the log file that last* commands should operate on. See also isLastOnly. */
|
/** Determines the log file that last* commands should operate on. See also isLastOnly. */
|
||||||
def lastLogFile(s: State) =
|
def lastLogFile(s: State) =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue