cernopendata / cernopendata-client

CERN Open Data command-line client
http://cernopendata-client.readthedocs.io/
GNU General Public License v3.0
10 stars 9 forks source link

get-metadata: amend `--output-fields` behaviour #41

Closed tiborsimko closed 4 years ago

tiborsimko commented 4 years ago

Stemming from #8 , we should also fix the behaviour of --output-fields. This currently allows to select only metadata, created, ... and other top-level fields from the /api/records output. This is not very useful.

While the power users can do things like:

$ cernopendata-client get-metadata --recid 1 | jq -S '.metadata.title'
"/BTau/Run2010B-Apr21ReReco-v1/AOD"
$ cernopendata-client get-metadata --recid 1 | jq -S '.metadata.system_details.global_tag'
"FT_R_42_V10A::All"

it would be useful to amend --output-fields to allow searching inside metadata section, so that users could write instead:

$ cernopendata-client get-metadata --recid 1 --output-fields title
/BTau/Run2010B-Apr21ReReco-v1/AOD
$ cernopendata-client get-metadata --recid 1 --output-fields system_details.global_tag
FT_R_42_V10A::All

IOW, --output-fields should be able to print out a wanted JSON path value directly.