- My scala program will be passed a list of numerical IDs on the command line
- I have a package of ~500 classes, where each class has a numerical ID
- I want to use only those classes whose IDs were passed on the command line
- I want to do this without writing out the names of all ~500 classes
For example with directory
MyClasses
- _001_first
- _002_second
- _003_third
where each class is sth like
class _001_first {val id = 1}
I'm looking for sth like
import MyClasses._
object Main extends App {
val instances = for (
MyClasses <- Class // I believe this is the problem line
inst = Class()
if args.contains(inst.id)
) yield inst
}
Is this possible? And if so, does anyone know the design decision behind why it's not possible? Suggestions for a completely different design are welcome
Context
I'm writing a test framework. Each test case will be in a separate file and I want to be able to specify on the command line which test cases to run.