Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how help is referenced to avoid initialization oddness & update case-app to 2.1.0-M29 #3152

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions modules/cli/src/main/scala/scala/cli/commands/ScalaCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import scala.cli.util.ConfigDbUtils.*
import scala.cli.{CurrentParams, ScalaCli}
import scala.util.{Properties, Try}

abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T], help: Help[T])
extends Command()(myParser, help)
abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T], inHelp: Help[T])
extends Command()(myParser, inHelp)
with NeedsArgvCommand with CommandHelpers with RestrictableCommand[T] {

private val globalOptionsAtomic: AtomicReference[GlobalOptions] =
new AtomicReference(GlobalOptions.default)

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

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

override val messages: Help[T] =
if shouldExcludeInSip then
Help[T](helpMessage =
inHelp.copy(helpMessage =
Some(HelpMessage(WarningMessages.powerCommandUsedInSip(
actualCommandName,
scalaSpecificationLevel
)))
)
else if isExperimental then
help.copy(helpMessage =
help.helpMessage.map(hm =>
inHelp.copy(helpMessage =
inHelp.helpMessage.map(hm =>
hm.copy(
message =
s"""${hm.message}
|
|${WarningMessages.experimentalSubcommandWarning(name)}""".stripMargin,
|${WarningMessages.experimentalSubcommandWarning(inHelp.progName)}""".stripMargin,
detailedMessage =
if hm.detailedMessage.nonEmpty then
s"""${hm.detailedMessage}
|
|${WarningMessages.experimentalSubcommandWarning(name)}""".stripMargin
|${WarningMessages.experimentalSubcommandWarning(inHelp.progName)}""".stripMargin
else hm.detailedMessage
)
)
)
else help
else inHelp

/** @param options
* command-specific [[T]] options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ final case class PackageOptions(
@HelpMessage("Generate a source JAR rather than an executable JAR")
@Name("sources")
@Name("src")
@Name("sourceJar")
@Tag(tags.restricted)
@Tag(tags.inShortHelp)
source: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ final case class PgpPushOptions(
@Group(HelpGroup.PGP.toString)
@HelpMessage("Whether to exit with code 0 if no key is passed")
allowEmpty: Boolean = false,
@Group(HelpGroup.PGP.toString)
@HelpMessage("When running Scala CLI on the JVM, force running scala-cli-singing using a native launcher or a JVM launcher")
@Hidden
forceSigningExternally: Boolean = false
) extends HasGlobalOptions
// format: on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ class InstallAndUninstallCompletionsTests extends ScalaCliSuite {
lazy val fishRcScript: String = {
val progName = "scala-cli"
val script =
s"""
complete $progName -a '($progName complete fish-v1 (math 1 + (count (__fish_print_cmd_args))) (__fish_print_cmd_args))'
|""".stripMargin
s"""complete $progName -a '($progName complete fish-v1 (math 1 + (count (__fish_print_cmd_args))) (__fish_print_cmd_args))'"""
Gedochao marked this conversation as resolved.
Show resolved Hide resolved
addTags(script)
}

Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ object Deps {
.exclude(("com.github.plokhotnyuk.jsoniter-scala", "jsoniter-scala-core_2.13"))
def bloopRifle = ivy"ch.epfl.scala:bloop-rifle_2.13:${Versions.bloop}"
def bsp4j = ivy"ch.epfl.scala:bsp4j:2.1.1"
def caseApp = ivy"com.github.alexarchambault::case-app:2.1.0-M28"
def caseApp = ivy"com.github.alexarchambault::case-app:2.1.0-M29"
def collectionCompat = ivy"org.scala-lang.modules::scala-collection-compat:2.12.0"
// Force using of 2.13 - is there a better way?
def coursier = ivy"io.get-coursier:coursier_2.13:${Versions.coursier}"
Expand Down
7 changes: 1 addition & 6 deletions website/docs/reference/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ Generate a library JAR rather than an executable JAR

### `--source`

Aliases: `--source-jar`, `--sources`, `--src`
Aliases: `--sources`, `--src`

Generate a source JAR rather than an executable JAR

Expand Down Expand Up @@ -2122,11 +2122,6 @@ Try to push the key even if Scala CLI thinks it's not a public key
[Internal]
Whether to exit with code 0 if no key is passed

### `--force-signing-externally`

[Internal]
When running Scala CLI on the JVM, force running scala-cli-singing using a native launcher or a JVM launcher

### Pgp scala signing options

Available in commands:
Expand Down
Loading