Project

General

Profile

Actions

Feature #21635

closed

Extensible commands in hammer

Added by Tomáš Strachota about 7 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Category:
Hammer core
Target version:
-
Difficulty:
Triaged:
No
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

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.:

HammerCLIForeman::Host::InfoCommand.extend(ComputeAttributesExtension.new)

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.

execute_extensions(:help, parameters)

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.


Related issues 3 (1 open2 closed)

Related to Hammer CLI - Feature #21633: Allow modification of additional help textsClosedOleh FedorenkoActions
Related to Hammer CLI - Feature #21634: Allow modification of output fieldsClosedOleh FedorenkoActions
Related to Hammer CLI - Feature #24655: Include details about the required options in the help text AssignedOleh FedorenkoActions
Actions

Also available in: Atom PDF