File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
compiler/src/dotty/tools/dotc/config Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,12 @@ package dotty.tools.dotc
22package config
33
44import java .nio .file .{Files , Paths }
5+
56import Settings ._
67import core .Contexts ._
78import util .DotClass
89import Properties ._
10+
911import scala .collection .JavaConverters ._
1012
1113object CompilerCommand extends DotClass {
@@ -71,7 +73,23 @@ object CompilerCommand extends DotClass {
7173 val ss = (ctx.settings.allSettings filter cond).toList sortBy (_.name)
7274 val width = (ss map (_.name.length)).max
7375 def format (s : String ) = (" %-" + width + " s" ) format s
74- def helpStr (s : Setting [_]) = s " ${format(s.name)} ${s.description}"
76+ def helpStr (s : Setting [_]) = {
77+ def defaultValue = s.default match {
78+ case _ : Int | _ : String => s.default.toString
79+ case _ =>
80+ // For now, skip the default values that do not make sense for the end user.
81+ // For example 'false' for the version command.
82+ " "
83+ }
84+ def formatSetting (name : String , value : String ) = {
85+ if (value.nonEmpty)
86+ // the format here is helping to make empty padding and put the additional information exactly under the description.
87+ s " \n ${format(" " )} $name: $value. "
88+ else
89+ " "
90+ }
91+ s " ${format(s.name)} ${s.description}${formatSetting(" Default" , defaultValue)}${formatSetting(" Choices" , s.legalChoices)}"
92+ }
7593 ss map helpStr mkString " \n "
7694 }
7795
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ object Settings {
8888 state.update(idx, x.asInstanceOf [T ])
8989 }
9090
91- def isDefaultIn (state : SettingsState ) = valueIn(state) == default
91+ def isDefaultIn (state : SettingsState ): Boolean = valueIn(state) == default
9292
9393 def legalChoices : String =
9494 if (choices.isEmpty) " "
You can’t perform that action at this time.
0 commit comments