Feature #19135
closed
Possibility to limit or add fields that are displayed
Added by Timo Goebel over 7 years ago.
Updated over 5 years ago.
Description
When using hammer cli it would be great if a user could say which columns / fields are printed when e.g. issuing a list command.
E.g. when I only want to see the name and vlanid column for subnet:
hammer subnet list --columns name,vlanid
- Status changed from New to Assigned
- Assignee set to Oleh Fedorenko
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/hammer-cli/pull/276 added
- Related to Feature #24110: hammer host list add fields domain_name and last_checkin added
I'm going to sum up design discussion about this feature. tstrachota, ofedoren feel free to update/comment.
Commands will get a new option '--fields' (--columns could be confusing for base output adapter used in info commands):
subnet list --fields name,vlanid
Feature 'field set' will add predefined sets of fields
- default field sets available for all commands are going to be THIN and ALL.
- THIN is just 'id, name' and should use '?thin=true' in API for max optimization
- fields and field sets can be added from plugins
- name is ALLCAPS to distinguish between field name and set
subnet list --fields THIN
Things to figure out:
- position of the option in the Main or end command?
- in main command it does not work with shell
- in individual commands it could conflict with options coming from API
- can plugins remove fields from field sets?
- allow combination of a field set and field names (host list --fields DEFAULT,my-filed)?
- how to define the default filed set?
- by field attribute :default => true/false (opt out) - hard to remove core filed from default set from plugin but works out of the box
- by explicitly defining the DEFAULT field set - it would bring better control for plugins but we have to define the set before adding non-default fields
position of the option in the Main or end command?
IMO it makes more sense to define it on the terminal command. I'd say that the chance for a name clash is minimal.
can plugins remove fields from field sets?
What would be the use-case for that?
allow combination of a field set and field names (host list --fields DEFAULT,my-filed)?
Definitely, it adds a lot of flexibilitty.
I'll add two things:
- The option must be able to consume field labels that are presented to users, not keys that are used for looking up the data in API responses. E.g. --fields="Puppet environment" vs. --fields=environment
- It should be possible to select nested fields like IPs of a NIC. E.g. --fields="Network interfaces/IP"
- Bugzilla link set to 1267445
- Has duplicate Feature #12293: Control the attributes which are returned from a list command added
- Pull request https://github.com/theforeman/hammer-cli-foreman/pull/407 added
- Status changed from Ready For Testing to Closed
Also available in: Atom
PDF