diff --git a/scripts/GithubCLI/README.md b/scripts/GithubCLI/README.md new file mode 100644 index 0000000..fb176e5 --- /dev/null +++ b/scripts/GithubCLI/README.md @@ -0,0 +1,22 @@ +# GitHub CLI With Python +This is a GitHub CLI utility using python. It aims to simplify daily github stats through powerful CLI ui + +## How to install? +1) Open CMD (Command Prompt) +2) Run python githubCLI.py --help to see all available commands + +## Available Commands +1) `python.exe main.py showall` - See all available projects for your account +2) `python.exe main.py showproject project` - See stats for your project. Replace project in command with project name +3) More commands coming soon! + +## Requirements? +-[ ] Replace `ADD_YOUR_OWN` in GitHub initialization using access token from GitHub +-[ ] Install typer using `pip install typer[all]` +-[ ] Install pygithub using `pip install pygithub` + +## Live action preview: + +![img.png](img.png) + +Hope you enjoy it! Made with ❤️ by Shatanik Mahanty diff --git a/scripts/GithubCLI/githubCLI.py b/scripts/GithubCLI/githubCLI.py new file mode 100644 index 0000000..41040c2 --- /dev/null +++ b/scripts/GithubCLI/githubCLI.py @@ -0,0 +1,62 @@ +from github import Github +from rich.console import Console +from rich.table import Table +import typer +from rich import print +from rich.panel import Panel +from rich.console import Group +import random + +app = typer.Typer() +console = Console() + +# Create your token from https://github.com/settings/tokens/new +# Select repo and user scope +g = Github("ADD_YOUR_OWN") + + +@app.command() +def showall(): + print("\n\n") + user = g.get_user() + table = Table("Repo Name", "URL", "Stars", "Open Issues", ) + for repo in user.get_repos(): + r = lambda: random.randint(0, 255) + color = str('#%02X%02X%02X' % (r(), r(), r())) + table.add_row("[bold " + color + "]" + repo.name, "[bold " + color + "]" + repo.url, + "[bold " + color + "]" + str(repo.stargazers_count), + "[bold " + color + "]" + str(repo.open_issues_count), + ) + group = Group( + table, + ) + print(Panel(group, title="[bold underline purple]All Repos of " + user.name)) + print("\n\n") + + +@app.command() +def showproject(name: str): + repo = g.get_user().get_repo(name=name) + print("\n\n") + table = Table("Name", "Contributions") + for contributor in repo.get_contributors(): + r = lambda: random.randint(0, 255) + color = str('#%02X%02X%02X' % (r(), r(), r())) + table.add_row("[bold " + color + "]" + contributor.name, + "[bold " + color + "]" + str(contributor.contributions)) + group = Group( + "[bold green]Owner:[/bold green] " + "[bold]" + repo.owner.name + "[/bold]\n" + "[bold blue]URL:[/bold blue] " + "[bold]" + repo.url + "[/bold]\n" + "[bold #ecc73c]Stars:[/bold #ecc73c] " + "[bold]" + str( + repo.stargazers_count) + "[/bold]", + "[bold blue]Forks:[/bold blue] " + "[bold]" + str(repo.forks_count) + "[/bold]", + "[bold #6a5b64]Watchers:[/bold #6a5b64] " + "[bold]" + str(repo.watchers_count) + "[/bold]", + "[bold red]Issues:[/bold red] " + "[bold]" + str(repo.open_issues_count) + "[/bold]", + table, + ) + print(Panel(group, title="[bold underline purple]Details of " + repo.name)) + print("\n\n") + + +if __name__ == "__main__": + app() diff --git a/scripts/GithubCLI/img.png b/scripts/GithubCLI/img.png new file mode 100644 index 0000000..92f16bd Binary files /dev/null and b/scripts/GithubCLI/img.png differ