Skip to content

Commit 7c9aae3

Browse files
authored
Enhance help message for language flag (#20247)
Fix #20083: Enhance help message for language features by displaying all available choises and notes
2 parents 4dffcc9 + 6a07b0a commit 7c9aae3

File tree

17 files changed

+55
-16
lines changed

17 files changed

+55
-16
lines changed

compiler/src/dotty/tools/dotc/config/CliCommand.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ trait CliCommand:
5353
end distill
5454

5555
/** Creates a help message for a subset of options based on cond */
56-
protected def availableOptionsMsg(p: Setting[?] => Boolean)(using settings: ConcreteSettings)(using SettingsState): String =
56+
protected def availableOptionsMsg(p: Setting[?] => Boolean, showArgFileMsg: Boolean = true)(using settings: ConcreteSettings)(using SettingsState): String =
5757
// result is (Option Name, descrption\ndefault: value\nchoices: x, y, z
5858
def help(s: Setting[?]): (String, String) =
5959
// For now, skip the default values that do not make sense for the end user, such as 'false' for the version command.
@@ -68,7 +68,10 @@ trait CliCommand:
6868
val ss = settings.allSettings.filter(p).toList.sortBy(_.name)
6969
val formatter = Columnator("", "", maxField = 30)
7070
val fresh = ContextBase().initialCtx.fresh.setSettings(summon[SettingsState])
71-
formatter(List(ss.map(help) :+ ("@<file>", "A text file containing compiler arguments (options and source files).")))(using fresh)
71+
var msg = ss.map(help)
72+
if showArgFileMsg then
73+
msg = msg :+ ("@<file>", "A text file containing compiler arguments (options and source files).")
74+
formatter(List(msg))(using fresh)
7275
end availableOptionsMsg
7376

7477
protected def shortUsage: String = s"Usage: $cmdName <options> <source files>"

compiler/src/dotty/tools/dotc/config/CompilerCommand.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abstract class CompilerCommand extends CliCommand:
99

1010
final def helpMsg(using settings: ConcreteSettings)(using SettingsState, Context): String =
1111
settings.allSettings.find(isHelping) match
12-
case Some(s) => s.description
12+
case Some(s) => availableOptionsMsg(_ == s, showArgFileMsg = false)
1313
case _ =>
1414
if (settings.help.value) usageMessage
1515
else if (settings.Vhelp.value) vusageMessage

0 commit comments

Comments
 (0)