Closed pkriens closed 2 years ago
@aleksandarmilicevic @eskang @grayswandyr are you ok if these commits that do not affect the language in any way, if I just commit them? We can always revert ... Just want to make a few more infra structure changes so Alloy will be easier to extend in the future.
There are numerous upcoming contestants for 'owning' the command line. Traditionally this is hard coded but this has the disadvantage that it creates a highly coupled network, which is hard to maintain.
This patch uses an annotation and some OSGi/bnd tooling to find all classes that want to add a command to the command line. The AlloyDispatcher gathers all those commands and then parses the command line. A library is used that uses an interface as specification for the options/flags and arguments. The library can then parse the command line, do error reporting, and provide extensive help.
Adding a new main looks like:
Any class in the build will be picked up.
The AlloyDispatcher can set the user A4Preferences, default log level, and class specific loglevels. A few commands like version and prefs are provided to show how the mechanism work.