Project

General

Profile

Feature #19135

Possibility to limit or add fields that are displayed

Added by Timo Goebel over 2 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Category:
Hammer core
Target version:
-
Team Backlog:
Fixed in Releases:
Found in Releases:

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


Related issues

Related to Hammer CLI - Tracker #14914: Tracker for output related issuesNew2016-05-03

Related to Hammer CLI - Feature #24110: hammer host list add fields domain_name and last_checkinNew
Has duplicate Hammer CLI - Feature #20743: Select certain fields for outputDuplicate2017-08-25
Has duplicate Hammer CLI - Feature #12293: Control the attributes which are returned from a list commandDuplicate

Associated revisions

Revision 4b12b87e (diff)
Added by Oleh Fedorenko 4 months ago

Fixes #19135 - Possibility to limit fields that are displayed (#276)

  • Fixes #19135 - Possibility to limit fields that are displayed

Revision e69943ba (diff)
Added by Oleh Fedorenko 4 months ago

Refs #19135 - Possibility to limit fields that are displayed (#407)

  • Refs #19135 - Possibility to limit fields that are displayed

History

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

#2 Updated by Tomáš Strachota about 2 years ago

  • Has duplicate Feature #20743: Select certain fields for output added

#3 Updated by Oleh Fedorenko over 1 year ago

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

#4 Updated by The Foreman Bot over 1 year ago

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

#5 Updated by Tomáš Strachota about 1 year ago

  • Related to Feature #24110: hammer host list add fields domain_name and last_checkin added

#6 Updated by Martin Bacovsky about 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,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

#7 Updated by Tomáš Strachota about 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"

#8 Updated by Tomáš Strachota about 1 year ago

  • Bugzilla link set to 1267445

#9 Updated by Tomáš Strachota about 1 year ago

  • Has duplicate Feature #12293: Control the attributes which are returned from a list command added

#10 Updated by The Foreman Bot 8 months ago

  • Pull request https://github.com/theforeman/hammer-cli-foreman/pull/407 added

#11 Updated by Oleh Fedorenko 4 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF