Skip to content

Commit 9d31d73

Browse files
authored
Bug fix for new --run flag (#1068)
* Ensure that CPG is written to disk in `runBundle` * Introduce `--store` flag * Tell user where the logs are in `--run` executions
1 parent 71ea2ae commit 9d31d73

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ case class Config(
1919
src: Option[String] = None,
2020
language: Option[String] = None,
2121
overwrite: Boolean = false,
22+
store: Boolean = false,
2223
server: Boolean = false,
2324
serverHost: String = "localhost",
2425
serverPort: Int = 8080,
@@ -85,6 +86,10 @@ trait BridgeBase {
8586
.action((_, c) => c.copy(overwrite = true))
8687
.text("Overwrite CPG if it already exists")
8788

89+
opt[Unit]("store")
90+
.action((_, c) => c.copy(store = true))
91+
.text("Store graph changes made by bundle")
92+
8893
note("REST server mode")
8994

9095
opt[Unit]("server")
@@ -188,19 +193,24 @@ trait BridgeBase {
188193
val bundleName = config.bundleToRun.get
189194
val src = config.src.get
190195
val language = config.language.getOrElse("c")
196+
val storeCode = if (config.store) { "save" } else { "" }
191197
val code = s"""
192198
| if (${config.overwrite} || !workspace.projectExists("$src")) {
193199
| importCode.$language("$src")
200+
| save
194201
| } else {
195202
| println("Using existing CPG - Use `--overwrite` if this is not what you want")
196203
| workspace.projects
197204
| .filter(x => x.inputPath == better.files.File("$src").path.toAbsolutePath.toString)
198205
| .map(_.name).map(open)
199206
| }
200207
| run.$bundleName
208+
| $storeCode
201209
|""".stripMargin
202210

203-
val file = new java.io.File("run-log.txt");
211+
val logFileName = "run-log.txt"
212+
println(s"Detailed logs at: $logFileName")
213+
val file = new java.io.File(logFileName);
204214
val fos = new FileOutputStream(file);
205215
val ps = new PrintStream(fos);
206216
System.setErr(ps)

0 commit comments

Comments
 (0)