How to do grep inside sbt

I use sbtScala to create my project, and I was looking for a way to filter the output of any command (e.g. compile) by a substring. In particular, I want to use grepin conjunction with sbt commands. For example, > compile | grep MyFile.scalait should print only the lines where it was specified MyFile.scala.

Is there any way to do this?

$ sbt --version
sbt launcher version 0.13.5
+4
source share
2 answers

The best way to grep SBT output interactively (tested with sbt 0.13.11) is to use last-grep.

This will reprint the output of the last command, and it will accept different grep-like arguments.

+5
source

, sbt, ?

$ sbt "tasks" | grep 'clean'

clean    Deletes files produced by the build, such as generated sources, compiled classes, and task caches.

, :

$ sbt "tasks" | grep 'class'
  clean   Deletes files produced by the build, such as generated sources, compiled classes, and task caches.

  console   Starts the Scala interpreter with the project classes on the classpath.

  consoleProject   Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.

  consoleQuick   Starts the Scala interpreter with the project dependencies on the classpath.

  run   Runs a main class, passing along arguments provided on the command line.

  runMain   Runs the main class selected by the first argument, passing the remaining arguments to the main method.
0

Source: https://habr.com/ru/post/1569529/


All Articles