Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package dotty.tools.dotc
package config
import scala.language.unsafeNulls
import Settings.*
import core.Contexts.*
import printing.Highlighting
import scala.util.chaining.given
import scala.PartialFunction.cond
trait CliCommand:
type ConcreteSettings <: CommonScalaSettings with Settings.SettingGroup
def versionMsg: String
def ifErrorsMsg: String
/** The name of the command */
def cmdName: String
def isHelpFlag(using settings: ConcreteSettings)(using SettingsState): Boolean
def helpMsg(using settings: ConcreteSettings)(using SettingsState, Context): String
private def explainAdvanced = """
|-- Notes on option parsing --
|Boolean settings are always false unless set.
|Where multiple values are accepted, they should be comma-separated.
| example: -Xplugin:plugin1,plugin2
| means one or a comma-separated list of:
| - (partial) phase names with an optional "+" suffix to include the next phase
| - the string "all"
| example: -Xprint:all prints all phases.
| example: -Xprint:typer,mixin prints the typer and mixin phases.
| example: -Ylog:erasure+ logs the erasure phase and the phase after the erasure phase.
| This is useful because during the tree transform of phase X, we often
| already are in phase X + 1.
"""
/** Distill arguments into summary detailing settings, errors and files to main */
def distill(args: Array[String], sg: Settings.SettingGroup)(ss: SettingsState = sg.defaultState)(using Context): ArgsSummary =
// expand out @filename to the contents of that filename
def expandedArguments = args.toList flatMap {
case x if x startsWith "@" => CommandLineParser.expandArg(x)
case x => List(x)
}
sg.processArguments(expandedArguments, processAll = true, settingsState = ss)
end distill
/** Creates a help message for a subset of options based on cond */
protected def availableOptionsMsg(p: Setting[?] => Boolean)(using settings: ConcreteSettings)(using SettingsState): String =
// result is (Option Name, descrption\ndefault: value\nchoices: x, y, z
def help(s: Setting[?]): (String, String) =
// For now, skip the default values that do not make sense for the end user, such as 'false' for the version command.
def defaultValue = s.default match
case _: Int | _: String => s.default.toString
case _ => ""
val info = List(shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "")
(s.name, info.filter(_.nonEmpty).mkString("\n"))
end help
val ss = settings.allSettings.filter(p).toList.sortBy(_.name)
val formatter = Columnator("", "", maxField = 30)
val fresh = ContextBase().initialCtx.fresh.setSettings(summon[SettingsState])
formatter(List(ss.map(help) :+ ("@", "A text file containing compiler arguments (options and source files).")))(using fresh)
end availableOptionsMsg
protected def shortUsage: String = s"Usage: $cmdName