Skip to content

Commit b41a6c7

Browse files
Remove cli options extensions
1 parent 6cdbd1c commit b41a6c7

File tree

67 files changed

+1001
-1132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1001
-1132
lines changed

modules/build/src/main/scala/scala/build/Build.scala

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,31 @@ object Build {
6565
mainClasses: Seq[String],
6666
commandString: String,
6767
logger: Logger
68-
): Either[MainClassError, String] = {
68+
): Either[BuildException, String] = {
6969
val defaultMainClassOpt = sources.defaultMainClass
7070
.filter(name => mainClasses.contains(name))
71-
def foundMainClass =
71+
def foundMainClass: Either[BuildException, String] =
7272
mainClasses match {
7373
case Seq() => Left(new NoMainClassFoundError)
7474
case Seq(mainClass) => Right(mainClass)
7575
case _ =>
76-
inferredMainClass(mainClasses, logger).left.flatMap { mainClasses =>
77-
options.interactive
78-
.chooseOne(
79-
"Found several main classes. Which would you like to run?",
80-
mainClasses.toList
81-
)
82-
.toRight {
83-
SeveralMainClassesFoundError(
84-
::(mainClasses.head, mainClasses.tail.toList),
85-
commandString,
86-
Nil
87-
)
76+
inferredMainClass(mainClasses, logger)
77+
.left.flatMap { mainClasses =>
78+
options.interactive.flatMap { interactive =>
79+
interactive
80+
.chooseOne(
81+
"Found several main classes. Which would you like to run?",
82+
mainClasses.toList
83+
)
84+
.toRight {
85+
SeveralMainClassesFoundError(
86+
::(mainClasses.head, mainClasses.tail.toList),
87+
commandString,
88+
Nil
89+
)
90+
}
8891
}
89-
}
92+
}
9093
}
9194

9295
defaultMainClassOpt match {

modules/cli/src/main/scala/scala/cli/commands/ScalaCommand.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ import scala.build.internal.{Constants, Runner}
1717
import scala.build.options.{BuildOptions, Scope}
1818
import scala.build.{Artifacts, Logger, Positioned, ReplArtifacts}
1919
import scala.cli.commands.shared.{HasLoggingOptions, ScalacOptions, SharedOptions}
20-
import scala.cli.commands.util.CommonOps.*
20+
import scala.cli.commands.util.CommandHelpers
2121
import scala.cli.commands.util.ScalacOptionsUtil.*
22-
import scala.cli.commands.util.SharedOptionsUtil.*
23-
import scala.cli.commands.util.{CommandHelpers, FmtOptionsUtil}
2422
import scala.cli.{CurrentParams, ScalaCli}
2523
import scala.util.{Properties, Try}
2624

modules/cli/src/main/scala/scala/cli/commands/about/About.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import scala.build.Logger
66
import scala.build.internal.Constants
77
import scala.cli.CurrentParams
88
import scala.cli.commands.update.Update
9-
import scala.cli.commands.util.CommonOps.*
109
import scala.cli.commands.version.Version
1110
import scala.cli.commands.{CommandUtils, ScalaCommand}
1211

modules/cli/src/main/scala/scala/cli/commands/addpath/AddPath.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import java.io.File
77

88
import scala.build.Logger
99
import scala.cli.CurrentParams
10-
import scala.cli.commands.util.CommonOps.*
1110
import scala.cli.commands.{CustomWindowsEnvVarUpdater, ScalaCommand}
1211
import scala.util.Properties
1312

modules/cli/src/main/scala/scala/cli/commands/bloop/Bloop.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import scala.build.internal.OsLibc
1010
import scala.cli.CurrentParams
1111
import scala.cli.commands.ScalaCommand
1212
import scala.cli.commands.shared.{LoggingOptions, SharedOptions}
13-
import scala.cli.commands.util.CommonOps.*
14-
import scala.cli.commands.util.SharedCompilationServerOptionsUtil.*
15-
import scala.cli.commands.util.SharedOptionsUtil.*
1613
import scala.concurrent.Await
1714
import scala.concurrent.duration.Duration
1815

@@ -25,7 +22,7 @@ object Bloop extends ScalaCommand[BloopOptions] {
2522

2623
private def bloopRifleConfig0(opts: BloopOptions): BloopRifleConfig = {
2724

28-
// FIXME Basically a tweaked copy of SharedOptionsUtil.bloopRifleConfig
25+
// FIXME Basically a tweaked copy of SharedOptions.bloopRifleConfig
2926
// Some in progress BuildOptions / JavaOptions refactoring of mine should allow
3027
// to stop using SharedOptions and BuildOptions here, and deal with JavaOptions
3128
// directly.

modules/cli/src/main/scala/scala/cli/commands/bloop/BloopExit.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import scala.build.blooprifle.{BloopRifle, BloopRifleConfig}
66
import scala.build.{Logger, Os}
77
import scala.cli.CurrentParams
88
import scala.cli.commands.ScalaCommand
9-
import scala.cli.commands.util.CommonOps.*
10-
import scala.cli.commands.util.SharedCompilationServerOptionsUtil.*
119

1210
object BloopExit extends ScalaCommand[BloopExitOptions] {
1311
override def hidden = true

modules/cli/src/main/scala/scala/cli/commands/bloop/BloopOutput.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import scala.build.blooprifle.BloopRifleConfig
77
import scala.cli.CurrentParams
88
import scala.cli.commands.ScalaCommand
99
import scala.cli.commands.shared.{CoursierOptions, LoggingOptions}
10-
import scala.cli.commands.util.CommonOps.*
11-
import scala.cli.commands.util.SharedCompilationServerOptionsUtil.*
1210

1311
object BloopOutput extends ScalaCommand[BloopOutputOptions] {
1412

modules/cli/src/main/scala/scala/cli/commands/bloop/BloopStart.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import scala.build.options.{BuildOptions, InternalOptions}
99
import scala.build.{Logger, Os}
1010
import scala.cli.CurrentParams
1111
import scala.cli.commands.ScalaCommand
12-
import scala.cli.commands.util.CommonOps.*
1312
import scala.cli.commands.util.JvmUtils
14-
import scala.cli.commands.util.SharedCompilationServerOptionsUtil.*
1513
import scala.concurrent.Await
1614
import scala.concurrent.duration.Duration
1715

modules/cli/src/main/scala/scala/cli/commands/bsp/Bsp.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import scala.cli.CurrentParams
1414
import scala.cli.commands.ScalaCommand
1515
import scala.cli.commands.publish.ConfigUtil.*
1616
import scala.cli.commands.shared.SharedOptions
17-
import scala.cli.commands.util.CommonOps.*
18-
import scala.cli.commands.util.SharedOptionsUtil.*
1917
import scala.cli.config.{ConfigDb, Keys}
2018
import scala.concurrent.Await
2119
import scala.concurrent.duration.Duration
@@ -78,7 +76,7 @@ object Bsp extends ScalaCommand[BspOptions] {
7876

7977
val inputs = argsToInputs(args.all).orExit(logger)
8078
CurrentParams.workspaceOpt = Some(inputs.workspace)
81-
val configDb = options.shared.configDb
79+
val configDb = options.shared.configDb.orExit(logger)
8280
val actionableDiagnostics =
8381
options.shared.logging.verbosityOptions.actions.orElse(
8482
configDb.get(Keys.actions).getOrElse(None)

modules/cli/src/main/scala/scala/cli/commands/clean/Clean.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import scala.build.internal.Constants
77
import scala.build.{Logger, Os}
88
import scala.cli.commands.ScalaCommand
99
import scala.cli.commands.setupide.SetupIde
10-
import scala.cli.commands.util.CommonOps.*
1110
import scala.cli.{CurrentParams, ScalaCli}
1211

1312
object Clean extends ScalaCommand[CleanOptions] {

0 commit comments

Comments
 (0)