I am trying to find the best solution to make my Java application configurable over the command line. The issue I am facing is that I need to configure complex nested structures.
Example
Consider the following structure (words starting with a capital are classes, indenting notates attributes)
- InterfaceOptimizer
- AbstractProblem
- dimension
- populationSize
- numberOfRuns
- AbstractProblem
The first thing I need to select from the command line is a class that implements InterfaceOptimizer (e.g. java App -O SomeOptimizer). The next thing to select would be the AbstractProblem which by itself takes another parameter dimension (e.g. java App -O SomeOptimizer -- -P ConcreteProblem.
The issue here is that some parameters are parameters for a specific class and depend on what parameter was first given. ConcreteProblem might take different parameters than OtherProblem.
Tested Libraries
I tested args4j and commons-cli, but those both fail when trying to do what I need.
WEKA (a popular machine learning tool) seems to have implemented a solution for this problem, but it basically requires each class to implement it's own CLI parser (and they seem to have issues with consistency).
Is there any good solution (existing library?) to this problem? What would be the recommended pattern be to solve this?
LL(*)grammar and then use ANTLR.