Skip to content

FaizeenHoque/github-repo-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repository Analyzer CLI

A powerful command-line interface (CLI) tool for analyzing and exploring GitHub repositories. Fetch repository information, analyze multiple endpoints simultaneously, and access repository data using the GitHub API.

Features

Current Features:

  • 🔐 Secure Authentication - Store and manage GitHub personal access tokens locally
  • 📦 Repository Information - Get complete repository details including stars, forks, and issues
  • 👥 Contributors Analysis - View repository contributors and their statistics
  • User Profiles - Fetch and display GitHub user profile information and hovercard data
  • �💬 Multiple Endpoints - Query multiple repository endpoints simultaneously
  • 🌐 Languages Detection - See programming languages used in repositories
  • 🏷️ Tags & Topics - Explore repository tags, topics, and forks
  • 📊 Activity Tracking - Monitor repository activity and changes
  • 🛡️ Token Management - View and remove stored tokens securely
  • 📋 JSON Output - Formatted JSON responses printed to stdout

Installation

Prerequisites

  • Python 3.7 or higher
  • pip (Python package manager)

Setup

  1. Clone the repository:

    git clone https://github.com/FaizeenHoque/github-repo-analyzer.git
    cd github-repo-analyzer
  2. Install dependencies:

    pip install typer requests
  3. Run the CLI:

    python main.py --help

Usage

Authentication

Before accessing repositories, authenticate with your GitHub personal access token to avoid rate limits and access private repositories:

Save a token:

python main.py configauth YOUR_GITHUB_TOKEN

View current token:

python main.py configauth --view-auth

Remove token:

python main.py configauth --remove-auth

Note: Tokens are securely stored in ~/.github-repo-analyzer/config.json

Get Repository Information

Fetch and display repository information with various endpoint options:

Get basic repository details:

python main.py getrepo owner/repo

Get repository contributors:

python main.py getrepo owner/repo --list-repo-contributors

Get repository languages:

python main.py getrepo owner/repo --list-repo-languages

Query multiple endpoints simultaneously:

python main.py getrepo owner/repo --list-repo-contributors --list-repo-languages --list-repo-tags

Get User Profile Information

Fetch and display GitHub user profile information:

Get basic user profile:

python main.py getprofile username

Get user hovercard information:

python main.py getprofile username --get-hovercard

Get specific user information:

# Get user email
python main.py getprofile username --get-email

# Get user name
python main.py getprofile username --get-name

# Get user company
python main.py getprofile username --get-company

# Get user blog
python main.py getprofile username --get-blog

# Get user location
python main.py getprofile username --get-location

# Get user bio
python main.py getprofile username --get-bio

# Get user X/Twitter handle
python main.py getprofile username --get-x
python main.py getprofile username --get-twitter

Example Output:

{
  "name": "repo-name",
  "full_name": "owner/repo",
  "description": "Repository description",
  "stargazers_count": 100,
  "forks_count": 50,
  "open_issues_count": 10,
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-12-30T00:00:00Z"
}

Commands Reference

Command Description Usage
configauth Manage GitHub authentication python main.py configauth [TOKEN]
getrepo Get repository information python main.py getrepo OWNER/REPO [...FLAGS]
getprofile Get user profile information python main.py getprofile USERNAME [...FLAGS]

Options

configauth:

  • TOKEN - GitHub personal access token (optional)
  • --view-auth - Display currently saved token
  • --remove-auth - Remove stored authentication token

getrepo:

  • repo_url - Repository in format owner/repo (required)
  • --list-repo-activities - Lists detailed history of changes to the repository
  • --list-repo-contributors - Lists contributors to the repository
  • --list-repo-languages - Lists programming languages used in the repository
  • --list-repo-tags - Lists tags associated with the repository
  • --list-repo-teams - Lists teams associated with the repository
  • --get-repo-topics - Lists topics associated with the repository
  • --list-repo-forks - Lists forks of the repository

Note: Multiple flags can be used together to fetch multiple endpoints in one command.

getprofile:

  • user_id - GitHub username (required)
  • --get-hovercard - Provides hovercard information about the user in relation to their pull requests, issues, repositories, and organizations
  • --get-email - Provides the public email address of the user
  • --get-name - Provides the public name of the user
  • --get-company - Provides the public company of the user
  • --get-blog - Provides the public blog URL of the user
  • --get-location - Provides the public location of the user
  • --get-bio - Provides the public bio of the user
  • --get-x - Provides the public X handle of the user
  • --get-twitter - Provides the public Twitter handle of the user

Getting a GitHub Token

  1. Go to GitHub Settings > Developer Settings > Personal Access Tokens
  2. Click "Generate new token" (classic)
  3. Select scopes:
    • repo - Full control of private repositories
    • public_repo - Access public repositories
  4. Copy the generated token
  5. Use with python main.py configauth YOUR_TOKEN

Project Structure

github-repo-analyzer/
├── main.py                      # Main CLI application entry point
├── api.py                       # GitHub API interaction functions
├── auth.py                      # Authentication management
├── printcolors.py               # Terminal color utilities
├── commands/
│   ├── __init__.py              # Commands package
│   ├── auth_commands.py         # Authentication CLI commands
│   ├── repo_commands.py         # Repository CLI commands
│   └── profile_commands.py      # User profile CLI commands
├── README.md                    # Documentation
├── LICENSE                      # MIT License
└── __pycache__/                 # Python cache files

Architecture

The project follows a modular architecture:

  • main.py - Minimal entry point that registers commands
  • api.py - Contains all GitHub API request logic
  • commands/ - Separate modules for different command categories
    • auth_commands.py - Token management commands
    • repo_commands.py - Repository query commands
  • auth.py - Handles secure token storage and retrieval
  • printcolors.py - Terminal color formatting utilities

Configuration

Configuration files are stored at:

  • Windows: C:\Users\<username>\.github-repo-analyzer\config.json
  • Linux/Mac: ~/.github-repo-analyzer/config.json

Troubleshooting

"No GitHub Token found"

  • Authenticate using: python main.py configauth YOUR_TOKEN

"API rate limit exceeded"

  • Authenticate to increase rate limits from 60 to 5,000 requests/hour
  • Wait for rate limit reset (shown in error message)

"Not Found" error

  • Verify repository owner/name format: owner/repo
  • Ensure you have access to private repositories (authenticate first)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

For issues, questions, or suggestions:


Made with ❤️ for developers by developers

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages