antonmedv / fx

Terminal JSON viewer & processor
https://fx.wtf
MIT License
19.08k stars 438 forks source link

Expand one level under cursor in interactive mode #166

Closed cirosantilli closed 2 years ago

cirosantilli commented 3 years ago

test.json

{
  "name": "hello",
  "items": [
    {
      "name": "subitem 1",
      "items": [
        {
          "name": "sub subitem 1 1"
        },
        {
          "name": "sub subitem 1 2"
        },
        {
          "name": "sub subitem 1 3"
        }
      ]
    },
    {
      "name": "subitem 2",
      "items": [
        {
          "name": "sub subitem 2 1"
        },
        {
          "name": "sub subitem 2 2"
        },
        {
          "name": "sub subitem 2 3"
        }
      ]
    },
    {
      "name": "subitem 3",
      "items": [
        {
          "name": "sub subitem 3 1"
        },
        {
          "name": "sub subitem 3 2"
        },
        {
          "name": "sub subitem 3 3"
        }
      ]
    }
  ]
}

When I do:

fx test.json

first I see:

{
  "name": "hello",
  "items": […]
}

Now I move the cursor under items, click l and I see:

{
  "name": "hello",
  "items": [
    {…},
    {…},
    {…}
  ]
}

What I want if, from this state, to have a way to press a single key and see:

{
  "name": "hello",
  "items": [
    {
      "name": "subitem 1",
      "items": […]
    },
    {
      "name": "subitem 2",
      "items": […]
    },
    {
      "name": "subitem 3",
      "items": […]
    }
  ]
}

which gives an overview of that level with the names clearly shown.

To do that currently I have to go under those three {...} and hit l.

I could use L, but if the three is very deep and wide, I lose the ability to see the nice overview of name that I want, which will allow me to decide where to go deeper in my exploration next.

I likely can achieve that with queries, but it would be nice to do it just in interactive mode.

antonmedv commented 3 years ago

What is second key press on l on same key will open second level?

antonmedv commented 2 years ago

I rewrote the entire fx in golang. So I belove this issue is fixed.