-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #21634 - Allows modification of output fields
- Loading branch information
Showing
6 changed files
with
331 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Modify an existing command | ||
------------------------- | ||
|
||
### Modification of output fields | ||
|
||
Each command (as well as each field) might have its own | ||
output definition. You can modify the output definition of existing | ||
command or a specific field of that command by following output | ||
definition interface: | ||
|
||
```ruby | ||
# Inserts one or more fields. | ||
# Where: | ||
# :mode is one of [:before, :after, :replace] | ||
# :field_id is field's id or key. Field's label can be used if field does not | ||
# have id | ||
# :fields is one or more existing fields | ||
# :block is block of code with new fields | ||
insert(:mode, :field_id, fields) do | ||
label | ||
field | ||
collection | ||
end | ||
# Returns output definition of the command or field specified with path. | ||
# Where: | ||
# path = Array of :field_key or/and :field_id or/and 'field_label'] | ||
at(path) | ||
# Returns field from current output definition. | ||
find_field(:field_id) | ||
# Deletes all fields from current output definition. | ||
clear | ||
``` | ||
#### Examples | ||
```ruby | ||
# Change field's label | ||
HammerCLIForeman::Host::InfoCommand.output_definition | ||
.at(:path) | ||
.find_field(:id).label = 'New label' | ||
# Expand a field with new definition | ||
HammerCLIForeman::Host::InfoCommand.output_definition | ||
.at(['some', :path]) | ||
.insert(:replace, :not_container_field_id, [Fields::Field.new(:first => :one)]) do | ||
field nil, _('Label with new fields'), Fields::Label, field_id: :now_container_field_id do | ||
field :new_field1, _('New field 1') | ||
field :new_field2, _('New field 2') | ||
end | ||
end | ||
# Simplified version | ||
HammerCLIForeman::Host::InfoCommand.output_definition | ||
.insert(:before, :field_id, Fields::Field.new(:first => :one)) | ||
# Remove field | ||
HammerCLIForeman::Host::InfoCommand.output_definition | ||
.insert(:replace, :field_id) do; end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters