janeklb / gh-search

GitHub code search with full text regex filtering, from your cli.
42 stars 3 forks source link

Add a flag to write the output into a file #46

Closed sledigabel closed 3 years ago

sledigabel commented 3 years ago

It would be good to have an option to write the outputs into a file. The API calls check makes it hard to interact with pipes.

Bonus points if they can be of different formats (csv, yaml, json, etc).

janeklb commented 3 years ago

It would be good to have an option to write the outputs into a file.

Agreed! Time to finish up the “output formats” branch :) Would the fields just be: repo + file (nested for yaml and json, and flat for csv)?

The API calls check makes it hard to interact with pipes.

Is there a particular example you could provide for this? Theres an “is tty” check to prevent sending the progress line to stdout if the command is getting piped, so I thought this was covered but maybe not?

sledigabel commented 3 years ago

Didn't notice the tty thing :-) just browsed the code and assumed it would get piped too. Nice one. Any format would do, repo + file would work just great. Perhaps if the output is yaml or json, you can enrich the data from the API? (typically, whether the file path, whether or not it's a fork, can't think of anything else but i'm sure there's some relevant info out there) WDYT?