hedyhli / starcli

:sparkles: Browse trending GitHub projects from your command line
https://pypi.org/project/starcli/
MIT License
550 stars 50 forks source link

Shorten the star/fork/watch count like [1234 to 1K] when displaying stats #40

Closed hedyhli closed 4 years ago

hedyhli commented 4 years ago

As per title, shorten the star/fork/watch count like [1234 to 1K] when displaying the stats for a repo by default. And we could add an option (maybe --long-stats) to not do so and display the exact amount of stars. To see an example, you can look at the star counts of any within repo Screenshot

To do so, (assuming there aren't any methods from standard library to do it) we can add a helper function in starcli/layouts.py, which takes in a integer, and if it's greater than 100 or almost a thousand, it will return a string which is the shortened format. E.g.: 100 -> 100 999 -> 1K 2560 -> 2.5K And so on, if you have a better way, you can do so too