-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4005 command-line options help is incomplete #4018
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
Changes from 1 commit
7578c37
f169cbd
a2a0a0d
fab4c4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,14 @@ object CompilerCommand extends DotClass { | |
val ss = (ctx.settings.allSettings filter cond).toList sortBy (_.name) | ||
val width = (ss map (_.name.length)).max | ||
def format(s: String) = ("%-" + width + "s") format s | ||
def helpStr(s: Setting[_]) = s"${format(s.name)} ${s.description}" | ||
def formatSettings(name: String, value: String) = if (value.nonEmpty) format("\n") ++ s" $name: $value." else "" | ||
def helpStr(s: Setting[_]) = { | ||
val help = StringBuilder.newBuilder | ||
help.append(s"${format(s.name)} ${s.description}") | ||
help.append(formatSettings("Default", s.defaultValue)) | ||
help.append(formatSettings("Choices", s.legalChoices)) | ||
help.toString | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this code already using the |
||
} | ||
ss map helpStr mkString "\n" | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,13 @@ object Settings { | |
state.update(idx, x.asInstanceOf[T]) | ||
} | ||
|
||
def isDefaultIn(state: SettingsState) = valueIn(state) == default | ||
def isDefaultIn(state: SettingsState): Boolean = valueIn(state) == default | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we don’t need to add this type annotation, no? Otherwise, LGTM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the Boy Scout Rule and added this small thing :) Is it true that the public methods have to have the return type annotation? Please correct me if I am not right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see! Fine with me. |
||
def defaultValue: String = implicitly[ClassTag[T]] match { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would make it an inner method of def defaultValue(setting: Setting[_]): String = setting.default match {
case _: Int | _: String => setting.default.toString
case _ => ""
} |
||
case StringTag => default.asInstanceOf[String] | ||
case IntTag => default.asInstanceOf[Int].toString | ||
case _ => "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both branches could be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found that only for these tag classes there are meaningful default values. For example for the |
||
} | ||
|
||
def legalChoices: String = | ||
if (choices.isEmpty) "" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, why do we need to use
format
on\n
? I'm probably being slow (or rushed)...And expressions can go inside the s formatter...
Any chance we can use
s"\n${format(name)} ${format(value)}"
? That's closer to what we do inhelpStr
, and hopefully clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use

format("\n")
as a hack to start the second line with an empty first column for Default or Choices