Project

General

Profile

Feature #21635

Extensible commands in hammer

Added by Tomáš Strachota over 1 year ago. Updated 16 days ago.

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

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

Related to Hammer CLI - Feature #21633: Allow modification of additional help textsClosed
Related to Hammer CLI - Feature #21634: Allow modification of output fieldsClosed
Related to Hammer CLI - Feature #24655: Include details about the required options in the help text New

Associated revisions

Revision 107a5124 (diff)
Added by Oleh Fedorenko 16 days ago

Fixes #21635 - Extensible commands in hammer

History

#1 Updated by Tomáš Strachota over 1 year ago

  • Related to Feature #21633: Allow modification of additional help texts added

#2 Updated by Tomáš Strachota over 1 year ago

  • Related to Feature #21634: Allow modification of output fields added

#3 Updated by Oleh Fedorenko about 1 year ago

  • Assignee set to Oleh Fedorenko
  • Status changed from New to Assigned

#4 Updated by Shira Maximov 8 months ago

  • Related to Feature #24655: Include details about the required options in the help text added

#5 Updated by The Foreman Bot 7 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/hammer-cli/pull/291 added

#6 Updated by Oleh Fedorenko 16 days ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF