Repository: scala-steward-org/scala-steward (scala)

Issue:
Disabling sandbox is broken
For private repos I check out master and run steward with `--disable-sandbox`. Now I get an error `Cannot run program "firejail"` which is afaik the sandbox tool. Seems to me related to #2414

Pull request:
Fixes #2430

Patch:
diff --git a/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala b/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala
index 5091cc3d81..8bb0300577 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala
@@ -30,6 +30,7 @@ import org.scalasteward.core.util.dateTime.renderFiniteDuration
 import org.scalasteward.core.vcs.VCSType
 import org.scalasteward.core.vcs.VCSType.GitHub
 import org.scalasteward.core.vcs.github.GitHubApp
+
 import scala.concurrent.duration._
 
 object Cli {
@@ -141,8 +142,10 @@ object Cli {
     ).orEmpty
 
   private val enableSandbox: Opts[Boolean] =
-    flag("enable-sandbox", "Whether to use the sandbox").orFalse
-      .orElse(flag("disable-sandbox", "Whether to not use the sandbox").orTrue.map(!_))
+    flag("enable-sandbox", "Whether to use the sandbox")
+      .map(_ => true)
+      .orElse(flag("disable-sandbox", "Whether to not use the sandbox").map(_ => false))
+      .orElse(Opts(false))
 
   private val sandboxCfg: Opts[SandboxCfg] =
     (whitelist, readOnly, enableSandbox).mapN(SandboxCfg.apply)


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala b/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala
index a61cb48531..30cd5c42e2 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala
@@ -8,6 +8,7 @@ import org.scalasteward.core.application.Cli.EnvVar
 import org.scalasteward.core.application.Cli.ParseResult._
 import org.scalasteward.core.vcs.VCSType
 import org.scalasteward.core.vcs.github.GitHubApp
+
 import scala.concurrent.duration._
 
 class CliTest extends FunSuite {
@@ -73,6 +74,7 @@ class CliTest extends FunSuite {
       ).flatten
     )
 
+    assert(!obtained.processCfg.sandboxCfg.enableSandbox)
     assertEquals(obtained.workspace, File("a"))
     assertEquals(obtained.reposFile, File("b"))
     assertEquals(obtained.gitCfg.gitAuthor.email, "d")
@@ -80,6 +82,52 @@ class CliTest extends FunSuite {
     assertEquals(obtained.vcsCfg.login, "e")
   }
 
+  test("parseArgs: enable sandbox") {
+    val Success(obtained) = Cli.parseArgs(
+      List(
+        List("--workspace", "a"),
+        List("--repos-file", "b"),
+        List("--git-author-email", "d"),
+        List("--vcs-login", "e"),
+        List("--git-ask-pass", "f"),
+        List("--enable-sandbox")
+      ).flatten
+    )
+
+    assert(obtained.processCfg.sandboxCfg.enableSandbox)
+  }
+
+  test("parseArgs: sandbox parse error") {
+    val Error(obtained) = Cli.parseArgs(
+      List(
+        List("--workspace", "a"),
+        List("--repos-file", "b"),
+        List("--git-author-email", "d"),
+        List("--vcs-login", "e"),
+        List("--git-ask-pass", "f"),
+        List("--enable-sandbox"),
+        List("--disable-sandbox")
+      ).flatten
+    )
+
+    assert(clue(obtained).startsWith("Unexpected option"))
+  }
+
+  test("parseArgs: disable sandbox") {
+    val Success(obtained) = Cli.parseArgs(
+      List(
+        List("--workspace", "a"),
+        List("--repos-file", "b"),
+        List("--git-author-email", "d"),
+        List("--vcs-login", "e"),
+        List("--git-ask-pass", "f"),
+        List("--disable-sandbox")
+      ).flatten
+    )
+
+    assert(!obtained.processCfg.sandboxCfg.enableSandbox)
+  }
+
   test("parseArgs: fail if required option not provided") {
     val Error(obtained) = Cli.parseArgs(Nil)
     assert(clue(obtained).startsWith("Missing expected"))