Giter VIP home page Giter VIP logo

starcli's Introduction

  ___  ______    _     ____     ____   _     _
 / \ *   | |    /\    | |  \   / |  * | \   | \
 \  \    | |   /\ \   | |* /  |  |    | |   | |
  \  \   | |  /--\ \  | | \   |  |    | |   | |
 *_\./   ._| /    ._\ |_|  \_  \.|__. |_|_. |_|

Browse trending projects on Github from your command line $ _

checks pypi version pypi downloads per month Python Requirements Code style: black GitHub license MIT


starcli demo.gif

Features

  • Filters
    • Stars
    • Pushed date
    • Created date
    • User
    • Topic
    • Language
    • Spoken language
  • Use generic GitHub search API or GitHub trending
  • Auth token (optional)
  • Paged output
  • Different layouts

Prerequisites

  • Requires Python 3.6 or greater

Installation

pip3 install starcli

Usage

Usage: starcli [OPTIONS]

  Search and query GitHub repositories

Options:
  -l, --lang TEXT                 Language filter eg: python. (can be used
                                  multiple times)
  -S, --spoken-language TEXT      Spoken Language filter eg: en for English,
                                  zh for Chinese
  -c, --created TEXT              Specify repo creation date in YYYY-MM-DD,
                                  use >date, <=date etc to be more specific.
  -t, --topic TEXT                Date of last push in YYYY-MM-DD (>, <, >=,
                                  <= specifiers supported)
  -p, --pushed TEXT               Specify date of last push in YYYY-MM-DD, >=<
                                  allowed
  -L, --layout [list|table|grid]  The output format (list, table, or grid),
                                  default is list
  -s, --stars TEXT                Number of stars, default is '>=100'. eg:
                                  '>0', '123', '<50000
  -n, --num-results INTEGER       The number of items in the results. Default:
                                  7
  -o, --order [desc|asc]          Order of repos by stars, 'desc' or 'asc',
                                  default: desc
  --long-stats                    Print the actual stats number (1300 instead
                                  of 1.3k)
  -d, --date-range [day|week|month]
                                  View stars received within time, choose
                                  from: day, week, month. Uses GitHub trending
                                  for fetching results, hence some other
                                  filter options may not work.
  -u, --user TEXT                 Filter for trending repositories by username
  --auth TEXT                     Optionally use GitHub personal access token
                                  in the format 'username:password'.
  -P, --pager                     Use $PAGER to page output. (put -r in $LESS
                                  to enable ANSI styles)
  --debug                         Turn on debugging mode
  --help                          Show this message and exit.

Layouts

Switch layouts using --layout {list|table|grid}, or use the short option -L

list

demo list

table

grid

demo grid

All three of the layout options support clickable links for repository names. If your terminal supports links, you can directly click on the name and it will take you to the GitHub repository in your browser.

Filtering by language

For example, you only want to find popular Python repos: using --lang or -l:

starcli --lang python

Here's another example starcli -l python -L grid, which is python with grid layout:

demo grid

Filtering by spoken language

If you wanted to find repos in your native language, you can use --spoken-language or -S:

starcli --spoken-language zh

The above command lists down repos written in Chinese.

A full list of language codes is available here

Note that (as with --date-range) options like --topics, --pushed, --created won't take effect because -d uses a different search mechanism to find results.

Specify the number (or range) of stars

(Recommended to be used with --created)

The default range is >=100 stars.

Use --stars or -s to specify what you want, for example, if you want to find repos that has more than 100 stars, you can use:

starcli -s '>100'

Note that if you do something like >1000 not many repos can have more than 1000 and is created within around 200 days (which is the default for --created), to specify date of creation, use --created, see below.

Filter by stars daily, weekly or monthly

You can view the number of stars a repo received today, this week or this month by using the --date-range or -d option:

starcli -d this-week -L table

This command will also display the number of stars received for each repo this week in the form of a table.

-d uses GitHub Trending search for repositories, hence options --topic, --pushed, --created won't take effect.

Specify the date of creation

--created/-c accepts a date in ISO8601 format: yyyy-mm-dd

For example, for repos created on 1st January 2014, use:

starcli --created 2014-01-01

To search for repos that are created on or after 1st January 2014, use:

starcli --created '>=2014-01-01'

Filtering by topics

This option lets you filter by topics. You can use --topics or -t to include a topic in search.

This option can be used multiple times.

starcli -l python -d 2020-07-06 -t deep-learning -t pytorch

Specifying last pushed date

Use --pushed/-p when you want to find popular repos that are last updated on a given date, say 2020-01-01 for 1st of Jan 2020:

starcli -p 2020-01-01

You can also prefix the value with ">=<" like:

starcli -p '>=2020-01-01'

This is find repos that have last pushed after or on January the 1st, 2020.

Read more about the >=< syntax on GitHub Docs.

Searching by user

Recommended to be used with --stars and/or --date-created.

Finding trending projects by GitHub username is supported too. Use --user or -u to do so.

Just provide a valid GitHub username after it, like:

starcli -u torvalds
starcli -u gvanrossum

Using date ranges

You can use --date-range or -d and specify today, this-week, or this-month, so that GitHub Trending search function will be used to find popular repos and tell you how much stars are gained this day/week/month depending on the option you used.

starcli -d this-week

demo date range

Note that (like --spoken-language) options like --topics, --pushed, --created won't take effect because -d uses a different search mechanism to find results.

Limit the number of results shown

Don't like the default 7? You can change it to something else, using --limit-results or -r followed by an integer:

starcli -r 2

The above will only give you two repos. This is useful if you want to put it in your .bashrc, .zshrc, or fish_greeting function.

Just add starcli -r 3 -L grid in there, and every time you open your terminal, you will find 3 trending repos printed neatly in a grid format, great way to start your day (a bit like the Hacker Tab Extension).

Paging

Result output can be displayed through your OS pager using the --pager/-p flag.

If you're using less, add R to your LESS environment variable so colors and styling can be displayed correctly.

GitHub Authentication

Rate limit may be hit if starcli sends many repeated requests to GitHub within a short perod of time.

To avoid this, provide an authentication token using --auth:

starcli --auth 'username:token'

Read more about authentication tokens on GitHub Docs

Issues, feature request, and feedback

  • Issues, bug reports, or feature request: Don't hesitate to open an issue in this repo
  • Feedback: any general feedback or questions about using StarCLI you can leave a comment on the Product Hunt page

Development PRs Welcome

For contributing guidelines and how to set up your development environment, please read CONTRIBUTING.md. Remember that all contributions to this project should follow its CODE OF CONDUCT.

Uses

  • CommandLine Argument parser: Click
  • Colored and table console print: rich (with click and colorama)
  • HTTP library to send requests: requests

Contributors ✨

Thanks goes to all of these wonderful people (emoji key):

Shagilton
Shagilton

πŸ’»
hexbee
hexbee

πŸ›
Sam Wellander
Sam Wellander

πŸ’»
Shivam Sinha
Shivam Sinha

πŸ’»
Will McGugan
Will McGugan

πŸ’»
Ashik J M
Ashik J M

πŸ’»
Yu-Lin Chao
Yu-Lin Chao

πŸ’»
Saif Kazi
Saif Kazi

πŸ’» πŸ“–
arcanearronax
arcanearronax

⚠️ πŸ’»
jSadoski
jSadoski

πŸ“– πŸ’»
odmishien(Tetsuya MISHIMA)
odmishien(Tetsuya MISHIMA)

πŸ’»
Neel Shah
Neel Shah

πŸ’»
0xflotus
0xflotus

πŸ’»
Akash Dhanwani
Akash Dhanwani

πŸ’»
Ed Davis
Ed Davis

πŸ’»
Jeff Chiang
Jeff Chiang

πŸ’»
Dmitry Kankalovich
Dmitry Kankalovich

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This project was forked from githunt (python) and its initial intention was to rewrite that project to use Rich instead of colorama + tabulate, but now it has so much more features than before, thanks to everyone's contributions πŸ™Œ

starcli's People

Contributors

0xflotus avatar acmalemzadeh avatar akashd-developer avatar allcontributors[bot] avatar arcanearronax avatar ashikjm avatar davised avatar dependabot-preview[bot] avatar dependabot[bot] avatar dzmitry-kankalovich avatar hedyhli avatar ineelshah avatar jsadoski avatar odmishien avatar saif807380 avatar shivam212 avatar swellander avatar tizee avatar willmcgugan avatar ylchao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starcli's Issues

Add usage screenshots/gif to README

Add screenshots of using it so people know what the output is, and how it feels like to run it...

Should demonstrate:

  • usage (help) output
  • list/table output
  • language, stars, limit results options

Better gif/svg animation of starcli usage/demo

The latest usage gif was outdated and since then there were new features and bug fixes. We should provide a new, up-to-date when to show the full features.

Requirements:

  • Shouldn’t be too slow, it is recommended that it is sped up, but users should see clearly what is happening
  • No need to show all the features, but show as much as possible
  • It should be run like a user who downloaded it as a package using starcli <args> not python -m starcli.
    To do so you have several options:
    1. clone this repo and do python setup.py install
    2. Make a new directory in a virtual environment and use pip install starcli (or you favourite package manager)
    3. Install starcli globally as a package like a normal user would
  • Once you have your SVG (or gif) saved, put it in the images folder (replace the original gif), update the link in the README and push to remote to open a PR

Some tools you could use:

If you would like to work on this, there is no need to ask, just open a PR. If there are multiple, I will choose one that works best or even include all of them

Bug: ValueError 'default' must be a list

Description

Python version: 3.9

your operating system (and terminal type of needed): macOS Terminal

starcli version: 2.17.0

any suggestions to the cause of the problem? (if possible)

Running starcli (with options --lang python -L list raises a value error:

"ValueError: 'default' must be a list when 'multiple' is true."

I think because of:

@click.option(
"--topic",
"-t",
default="",
multiple=True,  # <- this value
help="Search by topic, can be specified multiple times",

Bug: Error when trying to filter language to 'csharp' when also using '-d' filter

When filtering results, if using the language csharp on its own, it is fine, but if I add -d today, I get the error seen in the details dropdown below:

Error details

`-l csharp -d today`
zsh  starcli -l csharp -d today 
Traceback (most recent call last):
  File "/home/mosthated/.pyenv/versions/3.9.9/bin/starcli", line 8, in <module>
    sys.exit(cli())
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/starcli/__main__.py", line 183, in cli
    tmp_repos = search_github_trending(
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/starcli/search.py", line 233, in search_github_trending
    gtrending_repo_list = fetch_repos(
  File "/home/mosthated/.pyenv/versions/3.9.9/lib/python3.9/site-packages/gtrending/fetch.py", line 30, in fetch_repos
    raise ValueError(f"Invalid language argument: {language}")
ValueError: Invalid language argument: csharp

This demonstrates it not working, as well as working with the omission of the -d filter

# This works fine:
starcli -l csharp

# This does not
starcli -l csharp -d today

# I also tried a few others, but had the same results
starcli -l csharp -d this-week
starcli --lang csharp -d this-week
starcli -d today -l csharp 
starcli -d this-week -l csharp 

Just to check, I also tried the following, and it worked fine:

starcli -l rust -d today 

Python version
3.9.9

your operating system (and terminal type or shell of needed)

System Details
mosthated@pop-os
----------------
OS: Pop!_OS 21.10 x86_64
Host: X570 AORUS ELITE -CF
Kernel: 5.15.15-76051515-generic
Uptime: 7 days, 16 hours, 39 mins
Packages: 3947 (dpkg), 194 (brew), 76 (flatpak), 13 (snap)
Shell: zsh 5.8
Resolution: 1920x1080, 2560x1080, 1920x1080
DE: GNOME 40.5
WM: Mutter
WM Theme: Materia-dark-compact
Theme: Materia-dark-compact [GTK2/3]
Icons: Flatery-Orange-Dark [GTK2/3]
Terminal: alacritty
CPU: AMD Ryzen 9 3950X (32) @ 3.500GHz
GPU: NVIDIA GeForce RTX 2070
Memory: 53130MiB / 64314MiB

starcli version
starcli==2.17.1

UnicodeEncodeError on Raspbian

Currently being worked on in fix-unicode branch, error occurs with emoji.emojize because it can't display \u2470 (and other emojis) tested on Rasperry Pi Raspbian.

Bug: CONTRIBUTING.md - When using pipenv, must use --pre to install "black>=19.10b0" from requirements_dev.txt

Description

I know the current docs do not use pipenv, but I think it would be worthwhile to mention this issue in the docs to avoid confusion for others.

Command:

$ pipenv install --dev -r requirements_dev.txt
Creating a virtualenv for this project…
Pipfile: /Users/joe/Projects/jsadoski/starcli/Pipfile
Using /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 (3.7.0) to create virtualenv…
β ‡ Creating virtual environment...Already using interpreter /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/joe/.local/share/virtualenvs/starcli-3WcASgFr/bin/python3
Also creating executable in /Users/joe/.local/share/virtualenvs/starcli-3WcASgFr/bin/python
Installing setuptools, pip, wheel...done.

βœ” Successfully created virtual environment! 
Virtualenv location: /Users/joe/.local/share/virtualenvs/starcli-3WcASgFr
Creating a Pipfile for this project…
Requirements file provided! Importing into Pipfile…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
✘ Locking Failed! 
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches black>=19.10b0
[pipenv.exceptions.ResolutionFailure]:       Skipped pre-versions: 18.3a0, 18.3a0, 18.3a1, 18.3a1, 18.3a2, 18.3a2, 18.3a3, 18.3a3, 18.3a4, 18.3a4, 18.4a0, 18.4a0, 18.4a1, 18.4a1, 18.4a2, 18.4a2, 18.4a3, 18.4a3, 18.4a4, 18.4a4, 18.5b0, 18.5b0, 18.5b1, 18.5b1, 18.6b0, 18.6b0, 18.6b1, 18.6b1, 18.6b2, 18.6b2, 18.6b3, 18.6b3, 18.6b4, 18.6b4, 18.9b0, 18.9b0, 19.3b0, 19.3b0, 19.10b0, 19.10b0
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches black>=19.10b0
Skipped pre-versions: 18.3a0, 18.3a0, 18.3a1, 18.3a1, 18.3a2, 18.3a2, 18.3a3, 18.3a3, 18.3a4, 18.3a4, 18.4a0, 18.4a0, 18.4a1, 18.4a1, 18.4a2, 18.4a2, 18.4a3, 18.4a3, 18.4a4, 18.4a4, 18.5b0, 18.5b0, 18.5b1, 18.5b1, 18.6b0, 18.6b0, 18.6b1, 18.6b1, 18.6b2, 18.6b2, 18.6b3, 18.6b3, 18.6b4, 18.6b4, 18.9b0, 18.9b0, 19.3b0, 19.3b0, 19.10b0, 19.10b0
There are incompatible versions in the resolved dependencies.
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches black>=19.10b0
[pipenv.exceptions.ResolutionFailure]:       Skipped pre-versions: 18.3a0, 18.3a0, 18.3a1, 18.3a1, 18.3a2, 18.3a2, 18.3a3, 18.3a3, 18.3a4, 18.3a4, 18.4a0, 18.4a0, 18.4a1, 18.4a1, 18.4a2, 18.4a2, 18.4a3, 18.4a3, 18.4a4, 18.4a4, 18.5b0, 18.5b0, 18.5b1, 18.5b1, 18.6b0, 18.6b0, 18.6b1, 18.6b1, 18.6b2, 18.6b2, 18.6b3, 18.6b3, 18.6b4, 18.6b4, 18.9b0, 18.9b0, 19.3b0, 19.3b0, 19.10b0, 19.10b0
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches black>=19.10b0
Skipped pre-versions: 18.3a0, 18.3a0, 18.3a1, 18.3a1, 18.3a2, 18.3a2, 18.3a3, 18.3a3, 18.3a4, 18.3a4, 18.4a0, 18.4a0, 18.4a1, 18.4a1, 18.4a2, 18.4a2, 18.4a3, 18.4a3, 18.4a4, 18.4a4, 18.5b0, 18.5b0, 18.5b1, 18.5b1, 18.6b0, 18.6b0, 18.6b1, 18.6b1, 18.6b2, 18.6b2, 18.6b3, 18.6b3, 18.6b4, 18.6b4, 18.9b0, 18.9b0, 19.3b0, 19.3b0, 19.10b0, 19.10b0
There are incompatible versions in the resolved dependencies.

Python version

Python 3.7.0

your operating system (and terminal type if needed)

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.5
BuildVersion:   19F101

$ bash --version
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

starcli version

Current with ce0ba54.

any suggestions to the cause of the problem? (if possible)
Adding the --pre flag allows the installation of black (from: microsoft/vscode-python#5171).

$ pipenv install --dev -r requirements_dev.txt --pre
Requirements file provided! Importing into Pipfile…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
βœ” Success! 
Locking [packages] dependencies…
Updated Pipfile.lock (fc8d65)!
Installing dependencies from Pipfile.lock (fc8d65)…
  🐍   β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 46/46 β€” 00:00:14
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

Feat: Basic Authentication for Github API

Description

At this time, we're having issues hitting rate limits - especially when testing. GitHub only allows 10 requests/minute. Basic Authentication would allow up to 30/minute.

Why is it necessary? (or how would it make it better)

This is necessary to expand our ability to perform automated tests without those tests failing due to Rate Limit issues.

how do you think should it be implemented? (If possible)

I think we should use a username/api key in the request header for Basic Authentication. We could then just place the appropriate credentials in an environment variable and use click to access it. We could also cache the username/api key, which I presume we would want to do securely... Not sure how to do that without external modules or if our automated testing would support that.

I would love to work on this! I don't know much about the automated PR testing, however. I would need to know if we can run it with the env variable and which account credentials we would use for testing.

Add graph feature to show a star chart/graph of a repository

We can use probably a --graph option to display a graph of the star/fork/watcher or just the stars of one or more repositories, choosing a specific repository or display a graph for all repos fetched from search() is undecided. Play around and experiment with what you should do, if we are going to display a graph for every repo fetched, we should make the graph option one of the --layout choices.

Don't forget to update the help and usage both in __main__.py and also in the readme.

Caching request responses to prevent hitting rate limits

Description

GitHub API has rate limits, and sometimes when using starcli it takes up to 10+ secs to see the output, we should cache the responses based on options (like topic/stars/dates etc) somewhere so that when the user uses the same options again within say 1 minute, it can just fetch the cached info instead of sending the request again

Why is it necessary? (or how would it make it better)

This improves the execution speed/performance

how do you think should it be implemented? (If possible)

Every time search is called we cache the response together with the options used, so when the same options are used again we output the cached data instead

Filtering by spoken language (new option)

Currently we can only filter by language, date, and stars, we should also add --spoken-language option to filter by spoken language (Chinese, English, etc):
Screenshot_20200711_080341

Github API can probably filter it for us, if not, we might have to scrape it from the website.
Remember to update the readme when adding a new option

Search by Topic

  • related to any bug?

NO

  • why should this feature be implemented?

More and more projects are tagged with relevant keywords (topic). Search by language is sometimes too broad. I would like to search within javascript language by topic react.

  • how do you think should it be implemented?

Command line flag --topic -t Search by topic that is used in combination with language flag.

  • is the feature similar to anything from other projects?

Not sure

Add CLI tests (pytest) to test the CLI itself

Currently we only have a search() test (you can check out the tests dir), we probably need a way to emulate a real terminal and call it from that command line (With different options) to test the full functionality, can use: https://click.palletsprojects.com/en/7.x/testing/

Just add some test_*.py files in tests/ and in it add test_* functions to do your test. Then you can run python -m pytest and make sure they pass. We need these because they are part of the GitHub action workflow, all pull request and pushed commits will then be tested using it

Bug:

Description

I'm getting this error:

Exception has occurred: TypeError
style() got an unexpected keyword argument 'end'

when hitting this line:

https://github.com/hedythedev/starcli/blob/57ae9cdce0b3bddd27a1bbdb3b665a641c627fc7/starcli/__main__.py#L134

Python version

$ python --version
Python 3.7.0

your operating system (and terminal type of needed)

$ pip freeze | grep click
click==7.1.2

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.5
BuildVersion:   19F101

$ bash --version
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)

starcli version

57ae9cd

any suggestions to the cause of the problem? (if possible)
What is this line for? I can't find any documentation for it in click.secho or click.style.

Bug: TypeError: cli() got an unexpected keyword argument 'topic'

Description

Running starcli returned this error, as --topics was renamed but not changed in the cli() parameters.

Python version

$ python --version
Python 3.7.0

your operating system (and terminal type of needed)

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.5
BuildVersion:   19F101
$ bash --version
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)

starcli version

57ae9cd

any suggestions to the cause of the problem? (if possible)

Rename/refactor cli(.. topics, ...) --> cli(.. topic, ...)

Support for 3.6 and below: type object 'datetime.datetime' has no attribute 'fromisoformat'

Please check below errors, and it seems that fromisoformat is not available in Python versions older than 3.7 -> πŸ”— https://stackoverflow.com/questions/60266554/type-object-datetime-datetime-has-no-attribute-fromisoformat

python3 --version
Python 3.6.8
python3 -m starcli -l python
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "~/repos/starcli/starcli/__main__.py", line 63, in <module>
    search()
  File "~/py3venv_20200617/lib64/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "~/py3venv_20200617/lib64/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "~/py3venv_20200617/lib64/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "~/py3venv_20200617/lib64/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "~/repos/starcli/starcli/__main__.py", line 38, in search
    start_date = datetime.fromisoformat(
AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'

Add tests for cached results

Caching results was added in #97 by @AkashD-Developer, it would be nice if CLI tests were added for it.

The details of implementation is up to you, here's some ideas:

  • Checking for the cache json
  • Running same command again and time differences

Bug: Unable to launch starcli on a new machine - cache file missing

I went to install starcli on my personal MBP and ran into following problem:

starcli
Traceback (most recent call last):
  File "/opt/homebrew/bin/starcli", line 8, in <module>
    sys.exit(cli())
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/starcli/__main__.py", line 191, in cli
    with open(CACHED_RESULT_PATH, "a+") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/dkankalovich/.cache/starcli.json'

It seems like some regression happened in latest versions and now starcli expects that cache file to be present.

Python version

3.10

your operating system (and terminal type or shell of needed)

macOS 13.1 (22C65)

starcli version

starcli==2.17.1

reproduce

Delete ~/.cache dir and run starcli.

workaround

Create an empty json file:

mkdir -p /Users/dkankalovich/.cache && echo "{}" > /Users/dkankalovich/.cache/starcli.json

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

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

Add linkable jumping click?

Hi, thanks for this useful lib, can you add Add linkable jumping click? rich lib might support such feature, currently can not directly jumping to browser from terminal output

Use gtrending for fetching GitHub trending instead of scraping the web

Description

Using the gtrending library you can fetch trending repositories (and developers) by language, spoken language, and since (date range), we can replace this function in search and use the API from that instead.

Note that

  1. the keys (repo["stargazers_count"] etc) are different, so we would need a helper function to change the keys into the keys github uses.
  2. We might have to sort the order asc or desc ourselves after the repo list is returned.

Also notice how the wording is a bit different since and the current date-range, so it would be good to rename the CLI option as well to keep the wording the same. Don't forget to update the CLI tests when renaming the options.

And don't forget to update the requirements.txt and setup.py install requires because we don't need BeautifulSoup, lxml anymore, and add gtrending.

Support for windows: getting terminal width and height without using 'fcntl'

When running starcli on windows it throws the following error, because fcntl is not supported on windows:

Traceback (most recent call last):
  File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\<username>\AppData\Roaming\Python\Python38\Scripts\starcli.exe\__main__.py", line 9, in <module>
  File "C:\Users\<username>\AppData\Roaming\Python\Python38\site-packages\starcli\__main__.py", line 39, in cli
    list_layout(repos)
  File "C:\Users\<username>\AppData\Roaming\Python\Python38\site-packages\starcli\layouts.py", line 18, in list_layout
    term_width, _ = terminal_size()
  File "C:\Users\<username>\AppData\Roaming\Python\Python38\site-packages\starcli\terminal_size.py", line 6, in terminal_size
    import fcntl, termios, struct
ModuleNotFoundError: No module named 'fcntl'

In order to support windows, we need an alternative way (or extra way if the os is windows) to fetch the terminal width and height to be used in list layout printing. In other words, finding a substitute to fcntl to fetch terminal size info.

Bug: Rich v4: "AttributeError: 'Text' object has no attribute 'stylize_all'"

Description

Rich removed text.stylize_all() in version 4.0.

Textualize/rich@e784949: A better Text.stylize

$ python -m starcli
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/joe/Projects/starcli/starcli/__main__.py", line 139, in <module>
    cli()
  File "/Users/joe/Projects/starcli/venv/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/joe/Projects/starcli/venv/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/joe/Projects/starcli/venv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/joe/Projects/starcli/venv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/joe/Projects/starcli/starcli/__main__.py", line 134, in cli
    list_layout(repos)  # if layout isn't a grid or table, then use list.
  File "/Users/joe/Projects/starcli/starcli/layouts.py", line 97, in list_layout
    console.print(column(render_repo(repo)))
  File "/Users/joe/Projects/starcli/venv/lib/python3.7/site-packages/rich/console.py", line 188, in _replace
    return RenderGroup(*renderables, fit=fit)
  File "/Users/joe/Projects/starcli/starcli/layouts.py", line 59, in render_repo
    title.stylize_all(f"yellow link {repo['html_url']}")
AttributeError: 'Text' object has no attribute 'stylize_all'

Python version

$ python --version
Python 3.7.0

your operating system (and terminal type of needed)

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.5
BuildVersion:   19F101

$ bash --version
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

starcli version

8f92580

any suggestions to the cause of the problem? (if possible)

Either upgrade to rich>=4.0.0 and replace https://github.com/hedythedev/starcli/blob/8f92580119b5e68c2911067db2f8e18e775a9c2a/starcli/layouts.py#L59 with:

title.stylize(f"yellow link {repo['html_url']}")

(tested, works!)

or narrow the dependency to rich>=3.3.0,<4.0.0 (tested, pip installed rich-3.4.1 for me and worked!)
Which is better? I can make a PR for either route.

Feature: Search by User

Description

Create functionality to allow starcli to browse repos by Github user. This would display repos owned by the provided username.

Why is it necessary? (or how would it make it better)

This would allow the client to perform a more targeted search of repos. The client already displays the usernames for the owner of repos found. This would allow the client to further explore repos owned by an identified user, effectively adding a layer of depth to the existing breadth.

how do you think should it be implemented? (If possible)

A user would be able to pass a flag, such as "-U" or "--user" ("-u" is already used) to identify the user they want to find more repos for. When this flag is passed the API request would query the API for only the username, unless additional flags are provided. When a search by user is performed the same type of data about the repos will be displayed in the terminal, no change to the layout will occur.

Anything you would like to include

If this is acceptable, I can take on implementing this functionality.

Feat: View the main README.md from the terminal as well

Description
Hi all,

I put together this bash script that let's you view the main README.md for GitHub repos you find with this tool. This will only work with output format list. Let's say you run starcli -L list -t deep-learning -p '>=2020-11-20' -r 10 -l pytorch and you decide you want to look at one of those ten repos and view the README.md without leaving the terminal, and one of those repos is fastai/fastbook.

You'd create a shell script, say in your ~/Downloads path with vim viewREADME.sh and insert the following code:

#!/bin/bash

url=$1;
program=$2
base="https://raw.githubusercontent.com/";
file="README.md";
end="/master/README.md"

cd ~/Downloads;

curl -H 'Authorization: token INSERT_PERSONAL_TOKEN' \
  -H 'Accept: application/vnd.github.v3.raw' \
  -O \
  -L "${base}${url}${end}"

sleep 5

if [ ${program} = "glow" ]; then
    ${program} -s dark ${file}
else
    ${program} ${file}
fi

sleep 2

rm ${file}

This script has a couple prerequisites. You need to install a program like glow or grip to handle the markdown file. Also, you'll need to get an access token from GitHub. You can follow this guide for the token Create a personal access token. Then update the code above with your personal access token. Once that is complete, you'd run ./viewREADME.sh fastai/fastbook glow to view the README.md for that repo.

I'm sure this script could be cleaned up a bit, or further customized, but it works for my purposes.

Why do you think it would be a good idea?

Easy access to the README.md file.


Checklist

  • I have checked for existing issues and this is not a duplicate

Filter with multiple languages

First, the project is very useful! Thanks for creating it! However, it's kinda embarrassing that we can only search on one language once a time.
Can we add multiple language support so that we can search based on various combination of languages? Like python and c++

Add grid view option to `--layout`, implement grid view output

Currently, for the --layout option we have list or table, it would be awesome if we also have a grid option so the output can be displayed in grid view format.

To do so we should add a function called something like grid_layout() in starcli/layouts.py, with one parameter repos. This function should then be imported from starcli/__main__.py using the same logic as list_layout and table_layout to be called when --layout grid is specified. Also, don't forget to update click.Choices(["list", "table", "grid"]) in the starcli/__main__.py, with the help argument updated and the usage copied to the README.

You can use the panel and columns functionality from rich. See this example for reference

Start a pull request when you are done (or have started the draft PR)

Edit: added columns link as to the suggestion from @willmcgugan

Show +XX stars today, week, month, like in github trending page

In github explore, the trending tab, we will find this:
Screenshot_20200711_074246

We should also put something like this "+xx stars today" in our output, could probably start with list layout and see how it goes.

Also, we could add a new option --date-range like the following screenshot:
Screenshot_20200711_074542

The new option could use the click.Choice to have a choice between today, week, or month like the above picture. If you don't know how to do the choice you can check out the --layout or --order in __main__.py line 20:
https://github.com/hedythedev/starcli/blob/938d96ae9852a1436dbd47068aeaa651bcc49850/starcli/__main__.py#L17-L22

Not sure if the github API can provide the information, if not we might have to scrape the data from the website itself: https://github.com/trending?since=weekly change weekly to daily, monthly etc.

Remember to update the readme if you are adding and/or modifying the date options

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.