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
SI-9154 scalac offers extra help on bad option #4336
Conversation
/synch |
Logged jenkins issue at scala/scala-jenkins-infra#34 |
Could you squash these please -- I think it's small enough a change for one commit. |
If one of the help settings is on (-help, -X, -Y), then on a bad option, scalac reports similar options. For example, I know there's an option for showing things: ``` $ skalac -help -show scalac error: bad option: '-show' Similar options: -Xshow-class -Xshow-object -Xshow-phases -Yshow -Yshow-member-pos -Yshow-symkinds -Yshow-symowners -Yshow-syms -Yshow-trees -Yshow-trees-compact -Yshow-trees-stringified `scalac -help` gives more information ``` The `-debug` option is a little whacky, unfortunately, but this incantation works: ``` $ skalac -X -Xdebug scalac error: bad option: '-Xdebug' Similar options: -Ydebug -Ydoc-debug -Yide-debug -Yissue-debug -Ymacro-debug-lite -Ymacro-debug-verbose -Ypatmat-debug -Ypos-debug -Ypresentation-debug -Yquasiquote-debug -Yreify-debug -Ytyper-debug `scalac -help` gives more information ``` But don't suggest deprecated options. For instance, no evil `-Yinfer-debug`.
32f1103
to
75854f0
Compare
And so the mystery continues! |
@@ -14,7 +14,8 @@ abstract class Driver { | |||
protected var settings: Settings = _ | |||
|
|||
protected def scalacError(msg: String): Unit = { | |||
reporter.error(FakePos("scalac"), msg + "\n scalac -help gives more information") | |||
val indent = "\u0020" * 2 | |||
reporter.error(FakePos("scalac"), f"${msg}%n${indent}`scalac -help` gives more information") |
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.
Fancy! Though maybe more so than necessary?
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.
You're right as usual. I'll change it to:
scala> f"$msg%n${""}%2sMore."
res0: String =
hello world
More.
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 mean, I know you got f-interpolation on your mind and all, but... just saying.
Also, levenshtein? |
Sure, my use case was show and debug, with limited development resources. One hates to overinvest before the POC passes the first hurdles. |
It doesn't have to be fancy, but something to rank strings by similarity would be of great |
Since the 2.11.6 deadline is extremely nigh, I've tentatively postponed this PR (along with other recent ones) to 2.11.7. I'll make a pass through reviewed 2.11.7 PRs on Friday and move them back to 2.11.6 where feasible. In the mean time, feel free to let me know if you'd like some help getting this reviewed by then. |
For a general utility I'd favor a fragmented sequence alignment-type algorithm over Levenshtein distance because if I type |
@@ -14,7 +14,8 @@ abstract class Driver { | |||
protected var settings: Settings = _ | |||
|
|||
protected def scalacError(msg: String): Unit = { | |||
reporter.error(FakePos("scalac"), msg + "\n scalac -help gives more information") | |||
val indent = "\u0020" * 2 |
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.
This seems superfluous unless you intend some tab-like behavior with indentation (which isn't here). Just stick two spaces in in place of ${indent}
below?
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'll use a formatting width as in my reply to adriaan. Two spaces is too hard to verify at a glance, even in monospace.
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.
BTW, yes I got carried away.
If one of the help settings is on (-help, -X, -Y), then
on a bad option, scalac reports similar options.
For example, I know there's an option for showing things:
The
-debug
option is a little whacky, unfortunately, but thisincantation works:
This is more mnemonic assistance than help for newbies.