Skip to content

Commit 58838a5

Browse files
authored
repl: add --runBefore config option (#5165)
1 parent 8378c2b commit 58838a5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

console/src/main/scala/io/joern/console/BridgeBase.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ case class Config(
1414
command: Option[String] = None,
1515
params: Map[String, String] = Map.empty,
1616
predefFiles: Seq[Path] = Nil,
17+
runBefore: Seq[String] = Nil,
1718
additionalClasspathEntries: Seq[String] = Seq.empty,
1819
addPlugin: Option[String] = None,
1920
rmPlugin: Option[String] = None,
@@ -73,6 +74,13 @@ trait BridgeBase extends InteractiveShell with ScriptExecution with PluginHandli
7374
.action((x, c) => c.copy(predefFiles = c.predefFiles :+ x))
7475
.text("given source files will be compiled and added to classpath - this may be passed multiple times")
7576

77+
opt[String]("runBefore")
78+
.valueName("'import Int.MaxValue'")
79+
.unbounded()
80+
.optional()
81+
.action((x, c) => c.copy(runBefore = c.runBefore :+ x))
82+
.text("given code will be executed on startup - this may be passed multiple times")
83+
7684
opt[String]("classpathEntry")
7785
.valueName("path/to/classpath")
7886
.unbounded()
@@ -223,6 +231,7 @@ trait BridgeBase extends InteractiveShell with ScriptExecution with PluginHandli
223231
config.forInputPath.foreach { name =>
224232
builder += s"""openForInputPath("$name")""".stripMargin
225233
}
234+
builder ++= config.runBefore
226235
builder.result()
227236
}
228237

project/Versions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Versions {
3131
val requests = "0.8.0"
3232
val scalaParallel = "1.0.4"
3333
val scalaParserCombinators = "2.4.0"
34-
val scalaReplPP = "0.3.5"
34+
val scalaReplPP = "0.3.6"
3535
val scalatest = "3.2.18"
3636
val scopt = "4.1.0"
3737
val semverParser = "0.0.6"

0 commit comments

Comments
 (0)