Possibility to limit or add fields that are displayed
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
#6 Updated by Martin Bacovsky over 1 year ago
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,vlanidFeature '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 THINThings 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
#7 Updated by Tomáš Strachota over 1 year ago
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"