Add lastGrep command

This commit is contained in:
Nafer Sanabria 2018-04-08 10:51:54 -05:00
parent 218621b745
commit 3e201cee4d
2 changed files with 23 additions and 4 deletions

View File

@ -40,7 +40,6 @@ import sbt.internal.util.{
Types Types
} }
import sbt.util.{ Level, Logger, Show } import sbt.util.{ Level, Logger, Show }
import sbt.internal.util.complete.{ DefaultParsers, Parser } import sbt.internal.util.complete.{ DefaultParsers, Parser }
import sbt.internal.inc.ScalaInstance import sbt.internal.inc.ScalaInstance
import sbt.compiler.EvalImports import sbt.compiler.EvalImports
@ -52,7 +51,6 @@ import xsbti.compile.CompilerCache
import scala.annotation.tailrec import scala.annotation.tailrec
import sbt.io.IO import sbt.io.IO
import sbt.io.syntax._ import sbt.io.syntax._
import java.io.{ File, IOException } import java.io.{ File, IOException }
import java.net.URI import java.net.URI
import java.util.{ Locale, Properties } import java.util.{ Locale, Properties }
@ -198,6 +196,7 @@ object BuiltinCommands {
startServer, startServer,
eval, eval,
last, last,
oldLastGrep,
lastGrep, lastGrep,
export, export,
boot, boot,
@ -452,8 +451,15 @@ object BuiltinCommands {
s s
} }
@deprecated("Use `lastGrep` instead.", "1.2.0")
def oldLastGrep: Command =
lastGrepCommand(OldLastGrepCommand, oldLastGrepBrief, oldLastGrepDetailed)
def lastGrep: Command = def lastGrep: Command =
Command(LastGrepCommand, lastGrepBrief, lastGrepDetailed)(lastGrepParser) { lastGrepCommand(LastGrepCommand, lastGrepBrief, lastGrepDetailed)
private def lastGrepCommand(name: String, briefHelp: (String, String), detail: String): Command =
Command(name, briefHelp, detail)(lastGrepParser) {
case (s, (pattern, Some(sks))) => case (s, (pattern, Some(sks))) =>
val (str, _, display) = extractLast(s) val (str, _, display) = extractLast(s)
Output.lastGrep(sks, str.streams(s), pattern, printLast)(display) Output.lastGrep(sks, str.streams(s), pattern, printLast)(display)

View File

@ -57,10 +57,23 @@ $ShowCommand <task>
def pluginsDetailed = pluginsBrief // TODO: expand def pluginsDetailed = pluginsBrief // TODO: expand
val LastCommand = "last" val LastCommand = "last"
val LastGrepCommand = "last-grep" val OldLastGrepCommand = "last-grep"
val LastGrepCommand = "lastGrep"
val ExportCommand = "export" val ExportCommand = "export"
val ExportStream = "export" val ExportStream = "export"
val oldLastGrepBrief =
(OldLastGrepCommand, "Shows lines from the last output for 'key' that match 'pattern'.")
val oldLastGrepDetailed =
s"""$OldLastGrepCommand <pattern>
Displays lines from the logging of previous commands that match `pattern`.
$OldLastGrepCommand <pattern> [key]
Displays lines from logging associated with `key` that match `pattern`. The key typically refers to a task (for example, test:compile). The logging that is displayed is restricted to the logging for that particular task.
<pattern> is a regular expression interpreted by java.util.Pattern. Matching text is highlighted (when highlighting is supported and enabled).
See also '$LastCommand'."""
val lastGrepBrief = val lastGrepBrief =
(LastGrepCommand, "Shows lines from the last output for 'key' that match 'pattern'.") (LastGrepCommand, "Shows lines from the last output for 'key' that match 'pattern'.")
val lastGrepDetailed = val lastGrepDetailed =