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
542 stars 128 forks source link

`new` command should generate `.bsp/scala-cli.json` file #2230

Open lwronski opened 1 year ago

lwronski commented 1 year ago

Is your feature request related to a problem? Please describe.

When users run the new command, Scala CLI should generate a default .bsp/scala-cli.json file to enable IDE imports to work. This idea is based on the comment - https://github.com/VirtusLab/scala-cli/pull/2202#issuecomment-1597192591.

zetashift commented 1 year ago

For the implementation, can't the new command just call https://github.com/VirtusLab/scala-cli/blob/92f069c1439c0431e90f4c3f5666670c43bd8bb4/modules/cli/src/main/scala/scala/cli/commands/setupide/SetupIde.scala#L61 at the end?

bishabosha commented 1 year ago

For the implementation, can't the new command just call

https://github.com/VirtusLab/scala-cli/blob/92f069c1439c0431e90f4c3f5666670c43bd8bb4/modules/cli/src/main/scala/scala/cli/commands/setupide/SetupIde.scala#L61

at the end?

most other commands, e.g. run, also call SetupIde.runSafe in their implementation, so probably best to follow that

zetashift commented 1 year ago

Thank you! I'll try to whip something up.

zetashift commented 1 year ago

For the implementation, can't the new command just call https://github.com/VirtusLab/scala-cli/blob/92f069c1439c0431e90f4c3f5666670c43bd8bb4/modules/cli/src/main/scala/scala/cli/commands/setupide/SetupIde.scala#L61

at the end?

most other commands, e.g. run, also call SetupIde.runSafe in their implementation, so probably best to follow that

I'm having trouble filling out the sharedOptions parameter for the new command because NewOptions doesn't have SharedOptions:

    SetupIde.runSafe(???, ???, logger, buildOptions, Some(name), Seq.empty)

I am unsure how to build these. I can do SharedOptions.inputs(...) but that one expects a lot of parameters so that gives me the impression I'm looking in the wrong direction.

lwronski commented 1 year ago

Hi @zetashift, I think it could be beneficial to add SharedOptions into the new command. This enable users to specify some configs for their project, such as the Scala version:

scala-cli new VirtusLab/scala-cli.g8 -S 2.13