Reputation: 3049
I have many main
s in a project and I can choose which one to run in sbt using
> runMain full.path.of.main.object.
Unfortunately this is too verbose. In my case it is easy to generate the path of the main object from something much shorter: a number. So I was wondering if I could define a new command in sbt such that I could use:
> go 2
and this would be the same as runMain full.path.of.main.object2
.
How can I do this?
Context: I have solved several Project Euler problems in Scala. Each solution has a different main and so far I have been compiling and running from the command line. I am new to sbt and am trying to use it with all solutions in the same project. Thus I want to choose which code to run given just the problem number.
Upvotes: 2
Views: 215
Reputation: 8064
you can define an sbt input task and use reflection for this http://www.scala-sbt.org/0.13.0/docs/Extending/Input-Tasks.html not trivial.
Upvotes: 2