Skip to content

Commit 48382f4

Browse files
coreyoconnorGedochao
authored andcommitted
change how help is referenced to avoid initialization oddness
1 parent 31a88e4 commit 48382f4

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ import scala.cli.util.ConfigDbUtils.*
3434
import scala.cli.{CurrentParams, ScalaCli}
3535
import scala.util.{Properties, Try}
3636

37-
abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T], help: Help[T])
38-
extends Command()(myParser, help)
37+
abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T], inHelp: Help[T])
38+
extends Command()(myParser, inHelp)
3939
with NeedsArgvCommand with CommandHelpers with RestrictableCommand[T] {
40+
4041
private val globalOptionsAtomic: AtomicReference[GlobalOptions] =
4142
new AtomicReference(GlobalOptions.default)
4243

@@ -83,7 +84,7 @@ abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T],
8384
val maxCommandLength: Int = names.map(_.length).max max 1
8485
val maxPotentialCommandNames = argv.slice(1, maxCommandLength + 1).toList
8586
validCommand(maxPotentialCommandNames).getOrElse(List(""))
86-
}.getOrElse(List(name)).mkString(" ")
87+
}.getOrElse(List(inHelp.progName)).mkString(" ")
8788

8889
protected def actualFullCommand: String =
8990
if actualCommandName.nonEmpty then s"$progName $actualCommandName" else progName
@@ -293,30 +294,30 @@ abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T],
293294

294295
override val messages: Help[T] =
295296
if shouldExcludeInSip then
296-
Help[T](helpMessage =
297+
inHelp.copy(helpMessage =
297298
Some(HelpMessage(WarningMessages.powerCommandUsedInSip(
298299
actualCommandName,
299300
scalaSpecificationLevel
300301
)))
301302
)
302303
else if isExperimental then
303-
help.copy(helpMessage =
304-
help.helpMessage.map(hm =>
304+
inHelp.copy(helpMessage =
305+
inHelp.helpMessage.map(hm =>
305306
hm.copy(
306307
message =
307308
s"""${hm.message}
308309
|
309-
|${WarningMessages.experimentalSubcommandWarning(name)}""".stripMargin,
310+
|${WarningMessages.experimentalSubcommandWarning(inHelp.progName)}""".stripMargin,
310311
detailedMessage =
311312
if hm.detailedMessage.nonEmpty then
312313
s"""${hm.detailedMessage}
313314
|
314-
|${WarningMessages.experimentalSubcommandWarning(name)}""".stripMargin
315+
|${WarningMessages.experimentalSubcommandWarning(inHelp.progName)}""".stripMargin
315316
else hm.detailedMessage
316317
)
317318
)
318319
)
319-
else help
320+
else inHelp
320321

321322
/** @param options
322323
* command-specific [[T]] options

project/deps.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ object Deps {
142142
.exclude(("com.github.plokhotnyuk.jsoniter-scala", "jsoniter-scala-core_2.13"))
143143
def bloopRifle = ivy"ch.epfl.scala:bloop-rifle_2.13:${Versions.bloop}"
144144
def bsp4j = ivy"ch.epfl.scala:bsp4j:2.1.1"
145-
def caseApp = ivy"com.github.alexarchambault::case-app:2.1.0-M28"
145+
def caseApp = ivy"com.github.alexarchambault::case-app:2.1.0-M29"
146146
def collectionCompat = ivy"org.scala-lang.modules::scala-collection-compat:2.12.0"
147147
// Force using of 2.13 - is there a better way?
148148
def coursier = ivy"io.get-coursier:coursier_2.13:${Versions.coursier}"

0 commit comments

Comments
 (0)