Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing cli tables #31

Open
slavaGanzin opened this issue Jan 12, 2023 · 2 comments
Open

parsing cli tables #31

slavaGanzin opened this issue Jan 12, 2023 · 2 comments

Comments

@slavaGanzin
Copy link

slavaGanzin commented Jan 12, 2023

Hello, Abhimanyu. Awesome tool.

I used eat before and I want to switch to sttr, because of more general use cases covered by it, and because it's a single binary cli. Checks all the boxes.

What I do a lot with eat is parsing standard CLI tables like ps or docker images:

$ ps | eat

[
  {
    "PID": "5424",
    "TTY": "pts/1",
    "TIME": "00:00:00",
    "CMD": "fish"
  },
  {
    "PID": "6183",
    "TTY": "pts/1",
    "TIME": "00:00:00",
    "CMD": "ps"
  },
  {
    "PID": "6184",
    "TTY": "pts/1",
    "TIME": "00:00:00",
    "CMD": "node"
  },
  {
    "PID": "6185",
    "TTY": "pts/1",
    "TIME": "00:00:00",
    "CMD": "xclipm"
  }
]

I use this as a preprocessing step before manipulating data with something like jq or fx

Actually, I implemented this in eat. Code is super easy, but it works.
antonmedv/eat@0c2bec8#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R79-R81

Maybe you could look into it.

@abhimanyu003
Copy link
Owner

abhimanyu003 commented Jan 12, 2023

Hello @slavaGanzin
Thanks so much for your feedback and suggestion really appricate it.

I just installed eat. It seems to be breaking for me on mac

image

With docker images

image

I also tried couple of commands

ll | eat
ls -l | eat

Also what will happen if the table contains dash --- or === as row separation.

image

@slavaGanzin
Copy link
Author

slavaGanzin commented Jan 13, 2023

Thanks for investing time in this.

Yeah, right. I was using my own fork. Even if my PR was merged inside eat, the npm package was never really updated.

$ npm i -g slavaGanzin/eat

$ ps | eat                                                                                                                                          [
  {
    "PID": "58382",
    "TTY": "pts/4",
    "TIME": "00:00:02",
    "CMD": "fish"
  },
  {
    "PID": "62264",
    "TTY": "pts/4",
    "TIME": "00:00:00",
    "CMD": "ps"
  },
  {
    "PID": "62265",
    "TTY": "pts/4",
    "TIME": "00:00:00",
    "CMD": "nodem"
  }
]

Also what will happen if the table contains dash --- or === as row separation.

Usually, programs that render pretty tables, like this, has --json key :)
But you can substitute all table ascii symbols with spaces and that's it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants