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
2
2
package config
3
3
4
4
import java .nio .file .{Files , Paths }
5
+
5
6
import Settings ._
6
7
import core .Contexts ._
7
8
import util .DotClass
8
9
import Properties ._
10
+
9
11
import scala .collection .JavaConverters ._
10
12
11
13
object CompilerCommand extends DotClass {
@@ -71,7 +73,23 @@ object CompilerCommand extends DotClass {
71
73
val ss = (ctx.settings.allSettings filter cond).toList sortBy (_.name)
72
74
val width = (ss map (_.name.length)).max
73
75
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
+ }
75
93
ss map helpStr mkString " \n "
76
94
}
77
95
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ object Settings {
88
88
state.update(idx, x.asInstanceOf [T ])
89
89
}
90
90
91
- def isDefaultIn (state : SettingsState ) = valueIn(state) == default
91
+ def isDefaultIn (state : SettingsState ): Boolean = valueIn(state) == default
92
92
93
93
def legalChoices : String =
94
94
if (choices.isEmpty) " "
You can’t perform that action at this time.
0 commit comments