VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
551 stars 129 forks source link

UX problem: Make `latest` on by default when using --toolkit #2246

Open bjornregnell opened 1 year ago

bjornregnell commented 1 year ago

Version(s) 1.0.1

Describe the bug Misleading error messages when issuing scala-cli --toolkit lead to this failed session:

$ scala-cli --toolkit
Argument --toolkit: argument missing

To list all available options, run
  scala-cli --help

$ scala-cli --toolkit --help
Downloading 3 dependencies
[error]  Error downloading org.scala-lang:toolkit_3:--help
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/toolkit_3/--help/toolkit_3---help.pom
[error]   No fallback URL found
[error] Error downloading org.scala-lang:toolkit-test_3:--help
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/toolkit-test_3/--help/toolkit-test_3---help.pom
[error]   No fallback URL found
[error] COMMAND_LINE

Expected behaviour When an argument is missing the error message should show what argument can be used.

But in this case the whole UX failure could be prevented by just staring the repl with the latest toolkit on classpath.

Assuming latest by default seems reasonable from a user perspective.

bjornregnell commented 1 year ago

Also when detecting --help among options it should not start to assume its a library...

tgodzik commented 1 year ago

Thanks for reporting! As mentioned on discord, this is done on purpose to make people acknowledge they are not using a pinned toolkit version.

I wonder if instead we should have a warning when latest is used implicitely. Better for the users. The minimum we should do is do a better error message.

bjornregnell commented 1 year ago

Yes, well, I think it is better to allow start of the REPL, e.g. after acknowledging the toolkit version used, as a warning/message in terminal. I mean starting the repl is for experimentation and you don't know the version by hart. "Latest" is also cryptic and verbose to a beginner.

bjornregnell commented 1 year ago

It would also be cool if there was a setting to make a "naked" start of the repl (by scala-cli or later scala or scala-cli repl) would include the latest toolkit on classpath by default. This way the user can opt in for this more dynamic, beginnerfriendly "stdlib"... (compare how --power can be set to on by default and how that is suggested at its first use and automatically set to on after a question... Y/n)