jless
jless copied to clipboard
Add x/u/U commands to hide/unhide/unhide-all nodes
Proposed Feature: Ability to hide and unhide nodes
One of jless's major strength over simple pretty-printing of JSON is the interactivity it provides. This PR adds support for hiding and unhiding of individual map key nodes (based on jq query matching), enhancing the interactivity by allowing user to hide irrelevant nodes to better navigate and view the JSON.
The attached video demonstrates three features:
- Using
x
to hide individual object keys (ServiceId
,ServiceType
andAvailabilityZones
). Notice that the objects keys are hidden across all objects in theServiceDetails
array. - Using
u
to undo hiding of the above object keys one at a time - Using
U
to undo hiding of all object keys all at once
https://github.com/PaulJuliusMartinez/jless/assets/14101781/bdf0911d-f905-4a46-83d0-ee88402a579b
Changes
- Additional
vec<string>
field on theflatjson
struct to storejq
paths for testing which rows to hide.- When
x
is pressed, we generate thejq
path for the current node, and push it to the above vector. - When
u
is pressed, we pop the last item of the above vector. - When
U
is pressed, we clear the vector.
- When
- Update implementation of
flatjson::next_visible_row()
andflatjson::prev_visible_row()
to skip over hidden rows.- A row needs to be hidden if its
jq
path is included in the vector above.
- A row needs to be hidden if its