Yeah, this shouldn't be like this. You need an interface defining the common core of what it means to be an index, then all indexes implement this interface. You use the command line flag to set which class instantiates the interface at run time, but then following that, no code depends on that command line flag.