scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Support multiple main methods in scripts

Open tgodzik opened this issue 10 months ago • 2 comments

Is your feature request related to a problem? Please describe. After https://github.com/VirtusLab/scala-cli/pull/3479#event-16307192992 we will detect single main class if it's the only thing contained in the script and invoke that.

Describe the solution you'd like We should also allow user to define which main class to use if there is more that one for example:

object Main { def main(args: String): Unit = ??? }
object Main2 { def main(args: String): Unit = ??? }

Describe alternatives you've considered Using .scala files is a very simple workaround

tgodzik avatar Feb 14 '25 12:02 tgodzik

I don't get the motivation for this. I've never used a scripting language where scripts have multiple entry points. If you want the same script to do different things, you accept command line options.

SethTisue avatar Feb 14 '25 14:02 SethTisue

Yeah, I think we might never actually do it unless someone really needs it. This is more of a description of limitations.

tgodzik avatar Feb 14 '25 15:02 tgodzik