Reputation: 3367
I'm working on a node.js CLI tool that works with large json objects. I'd love to be able to display root nodes and then allow the user to expand and collapse object nodes as needed. Are there any packages available that setup this kind of functionality?
Here's an example of the kind of expand/collapse behavior I'm looking for in a browser
There's precedence for this kind of functionality in modules like Inquirer.js
Upvotes: 3
Views: 2043
Reputation: 3057
I haven't found a package that will setup completely the functionality you're looking for. But you could take a look at blessed (a fantastic library for terminal node-js applications).
Look under the lists widget and you have a highly extensible API for creating interactive lists (whether with the mouse, or the keyboard) inside a terminal.
You could use something like the items
option in the list which takes "an array of strings which become the list's items".
Or, you have the potential to use Blessed's Layout
widgets which mimic CSS functionality inside the terminal.
With that tool it shouldn't be very difficult to create a simple JSON
list that's interactive.
Upvotes: 2