github-tooling / ghtopdep

:star: CLI tool for sorting dependents repo by stars
MIT License
257 stars 18 forks source link

Option to export to file #32

Closed angularsen closed 4 months ago

angularsen commented 1 year ago

Piping the output to a file does not work well due to progress spinner output and any error messages are also included.

Problem

Running on Windows, Python 3.11, tried these shells:

pip install --upgrade ghtopdep
ghtopdep https://github.com/angularsen/UnitsNet --json > top.md

File output (shortened):

- Fetching information about repositories

\ Fetching information about repositories

| Fetching information about repositories

/ Fetching information about repositories

- Fetching information about repositories

\ Fetching information about repositories

| Fetching information about repositories

- Fetching information about repositories
[{"url": "https://github.com/microsoft/PowerToys", "stars": 105023}, {"url": "https://github.com/dotnet/iot", "stars": 2111}, {"url": "https://github.com/genielabs/HomeGenie", "stars": 388}, {"url": "https://github.com/raspberry-sharp/raspberry-sharp-io", "stars": 340}, {"url": "https://github.com/nanoframework/nanoFramework.IoT.Device", "stars": 202}, {"url": "https://github.com/porrey/Virtual-ZPL-Printer", "stars": 166}, {"url": "https://github.com/chino-os/chino-os", "stars": 147}, {"url": "https://github.com/BriefFiniteElementNet/BriefFiniteElement.Net", "stars": 143}, {"url": "https://github.com/WhiteBlackGoose/UnitsOfMeasure", "stars": 57}, {"url": "https://github.com/pi-top/pi-top-4-.NET-SDK", "stars": 48}]

Proposal

zer0yu commented 8 months ago

Hi, you can try my tool written in Go. I added the feature you mentioned. 😊

https://github.com/zer0yu/ghtracker

lnxpy commented 4 months ago

@angularsen It works perfectly fine for me.

ghtopdep https://github.com/lnxpy/pyaction --minstar 0 --json > file.json
angularsen commented 4 months ago

I can still repro on latest.

Running on Windows, Python 3.11, tried these shells:

pip install --upgrade ghtopdep
ghtopdep https://github.com/angularsen/UnitsNet --json > top.md

File output (shortened):

- Fetching information about repositories

\ Fetching information about repositories

| Fetching information about repositories

/ Fetching information about repositories

- Fetching information about repositories

\ Fetching information about repositories

| Fetching information about repositories

- Fetching information about repositories
[{"url": "https://github.com/microsoft/PowerToys", "stars": 105023}, {"url": "https://github.com/dotnet/iot", "stars": 2111}, {"url": "https://github.com/genielabs/HomeGenie", "stars": 388}, {"url": "https://github.com/raspberry-sharp/raspberry-sharp-io", "stars": 340}, {"url": "https://github.com/nanoframework/nanoFramework.IoT.Device", "stars": 202}, {"url": "https://github.com/porrey/Virtual-ZPL-Printer", "stars": 166}, {"url": "https://github.com/chino-os/chino-os", "stars": 147}, {"url": "https://github.com/BriefFiniteElementNet/BriefFiniteElement.Net", "stars": 143}, {"url": "https://github.com/WhiteBlackGoose/UnitsOfMeasure", "stars": 57}, {"url": "https://github.com/pi-top/pi-top-4-.NET-SDK", "stars": 48}]
lnxpy commented 4 months ago

You're right, @angularsen. Calling ghtopdep on the repositories with a tremendous amount of dependents causes that spinner to spin longer and when you pipe that into a file, those fetching statements would go there too.

I forked this repo and removed that spinning functionality. It should be fine now. ✨

Reinstallation

Simply remove the original version and install the fork.

pip uninstall -y ghtopdep
pip install git+https://github.com/lnxpy/ghtopdep@master

Usage

Run the example you showed, and you'll have the expected result.

ghtopdep https://github.com/angularsen/UnitsNet --json > top.json

In case you don't want to pipe anything, I also added the --output option that takes a file name and puts the result into the file. If you use both --output and --json, there will be nothing printed out into the STDOUT.

ghtopdep https://github.com/angularsen/UnitsNet --json --output top.json

You're welcome. ✨

angularsen commented 4 months ago

Impressively quick fix, thanks! Verified working here 👍

andriyor commented 2 months ago

i added progress bar and looks like this command works as expected ghtopdep https://github.com/angularsen/UnitsNet --json > top.md

lnxpy commented 2 months ago

Nice work, @andriyor! Not just the progress bar. The whole idea is just amazing. I made this discussion and asked GitHub to add an official endpoint for that. I'd really appreciate it if you could just upvote it and leave your thoughts. :))

https://github.com/orgs/community/discussions/123759

andriyor commented 2 months ago

here is related issue https://github.com/orgs/community/discussions/5575