Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

som-snytt
Copy link
Contributor

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
  -Yinfer-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

This is more mnemonic assistance than help for newbies.

@scala-jenkins scala-jenkins added this to the 2.11.6 milestone Feb 16, 2015
@adriaanm
Copy link
Contributor

/synch

@adriaanm
Copy link
Contributor

Logged jenkins issue at scala/scala-jenkins-infra#34

@adriaanm
Copy link
Contributor

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`.
@adriaanm
Copy link
Contributor

And so the mystery continues!

@som-snytt som-snytt closed this Feb 18, 2015
@som-snytt som-snytt reopened this Feb 18, 2015
@@ -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")
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@adriaanm
Copy link
Contributor

Also, levenshtein?

@som-snytt
Copy link
Contributor Author

Sure, my use case was show and debug, with limited development resources. One hates to overinvest before the POC passes the first hurdles.

@adriaanm
Copy link
Contributor

It doesn't have to be fancy, but something to rank strings by similarity would be of great utility.

@adriaanm adriaanm modified the milestones: 2.11.6, 2.11.7 Feb 19, 2015
@adriaanm
Copy link
Contributor

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.

@Ichoran
Copy link
Contributor

Ichoran commented Feb 20, 2015

For a general utility I'd favor a fragmented sequence alignment-type algorithm over Levenshtein distance because if I type debug-patmat I want it to bring up patmat-debug as the top entry. The penalty for rearrangements should not be as great as Levenshtein inflicts (i.e. you have to delete it all and add it all again). I don't have any reference code handy but I could write a routine.

@@ -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
Copy link
Contributor

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?

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'll use a formatting width as in my reply to adriaan. Two spaces is too hard to verify at a glance, even in monospace.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants