Extensible commands in hammer
Hammer doesn't provide any interface for extending commands. Currently all the extensions are done via including module, which is a dirty solution witout any clear boundaries.
There are several usecases already where hammer commands need to be dynamically extended:
- adding options and fields to host commands from katello
- adding per-provider fields in compute-resource info command
- adding help for per-provider options in host update and create
There are also some features not implemented yet that could take advantage of extension system in future:
- adding per-provider fields to compute profile commands
- adding extensions to ping command from plugins
All these cases could be refactorred to use a single extension solution that would make the implementation more flexible.
Extensions need to be able to modify the following:
- add options to commands
- extend data from server responses before it's printed
- extend and modify additional texts in help
- modify parameters of api requests
- modify output fields
The interface for extending should accept instances of extensions. E.g.:
Since some of the extension points are in hammer-cli and some in hammer-cli-foreman and there's potential for other plugins to add extension points in future, hammer should provide a helper function for invoking the extensions. E.g.
In the first phase it's fine to limit extension of options, help and print fields to allow only addition.
Full modification in this cases can be implemented later as it requires additional changes in hammer core.