Skip to content

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

Merged
merged 4 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package dotty.tools.dotc
package config

import java.nio.file.{Files, Paths}

import Settings._
import core.Contexts._
import util.DotClass
import Properties._

import scala.collection.JavaConverters._

object CompilerCommand extends DotClass {
Expand Down Expand Up @@ -71,7 +73,23 @@ 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 helpStr(s: Setting[_]) = {
def defaultValue = s.default match {
case _: Int | _: String => s.default.toString
case _ =>
// For now, skip the default values that do not make sense for the end user.
// For example 'false' for the version command.
""
}
def formatSetting(name: String, value: String) = {
if (value.nonEmpty)
// the format here is helping to make empty padding and put the additional information exactly under the description.
s"\n${format("")} $name: $value."
else
""
}
s"${format(s.name)} ${s.description}${formatSetting("Default", defaultValue)}${formatSetting("Choices", s.legalChoices)}"
}
ss map helpStr mkString "\n"
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object Settings {
state.update(idx, x.asInstanceOf[T])
}

def isDefaultIn(state: SettingsState) = valueIn(state) == default
def isDefaultIn(state: SettingsState): Boolean = valueIn(state) == default

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see! Fine with me.

def legalChoices: String =
if (choices.isEmpty) ""
Expand Down