|
| 1 | +# 🚀 GitHub Trending CLI |
| 2 | + |
| 3 | +A simple and elegant command-line tool to browse GitHub trending repositories with interactive navigation and README viewing. |
| 4 | + |
| 5 | +## ✨ Features |
| 6 | + |
| 7 | +- 📊 **Browse trending repositories** from GitHub's trending page |
| 8 | +- 📅 **Multiple time ranges**: daily, weekly, and monthly trends |
| 9 | +- 🧭 **Interactive navigation** to explore repositories |
| 10 | +- 📖 **README viewer** to read project documentation directly in terminal |
| 11 | +- 🎨 **Beautiful, modern interface** with Unicode box drawing, language-specific emojis, and trending indicators |
| 12 | +- ⚡ **Fast and lightweight** with minimal dependencies |
| 13 | + |
| 14 | +## 🛠️ Installation |
| 15 | + |
| 16 | +### Option 1: Install from source (Recommended) |
| 17 | + |
| 18 | +```bash |
| 19 | +# Clone the repository |
| 20 | +git clone https://github.com/your-username/github-trending-cli.git |
| 21 | +cd github-trending-cli |
| 22 | + |
| 23 | +# Create and activate virtual environment |
| 24 | +python3 -m venv venv |
| 25 | +source venv/bin/activate # On Windows: venv\Scripts\activate |
| 26 | + |
| 27 | +# Install dependencies |
| 28 | +pip install -r requirements.txt |
| 29 | + |
| 30 | +# Install the package |
| 31 | +pip install -e . |
| 32 | +``` |
| 33 | + |
| 34 | +### Option 2: Direct installation |
| 35 | + |
| 36 | +```bash |
| 37 | +# Install dependencies |
| 38 | +pip install requests beautifulsoup4 lxml |
| 39 | + |
| 40 | +# Run directly |
| 41 | +python -m github_trending.cli |
| 42 | +``` |
| 43 | + |
| 44 | +## ⚡ Quick Start |
| 45 | + |
| 46 | +```bash |
| 47 | +# After installation, simply run: |
| 48 | +github-trending |
| 49 | + |
| 50 | +# Or try different time ranges: |
| 51 | +github-trending --range weekly |
| 52 | +github-trending --range monthly |
| 53 | +``` |
| 54 | + |
| 55 | +## 🚀 Usage |
| 56 | + |
| 57 | +### Basic Commands |
| 58 | + |
| 59 | +```bash |
| 60 | +# Show today's trending repositories |
| 61 | +github-trending |
| 62 | + |
| 63 | +# Show this week's trending repositories |
| 64 | +github-trending --range weekly |
| 65 | + |
| 66 | +# Show this month's trending repositories |
| 67 | +github-trending --range monthly |
| 68 | + |
| 69 | +# Short form |
| 70 | +github-trending -r weekly |
| 71 | +``` |
| 72 | + |
| 73 | +### Interactive Navigation |
| 74 | + |
| 75 | +Once the tool displays the trending repositories, you can: |
| 76 | + |
| 77 | +- **Enter a number (1-25)** to view a repository's README |
| 78 | +- **Enter 'list' or 'l'** to show the repository list again |
| 79 | +- **Enter 'quit' or 'q'** to exit the application |
| 80 | + |
| 81 | +### Example Session |
| 82 | + |
| 83 | +```bash |
| 84 | +$ github-trending --range weekly |
| 85 | + |
| 86 | +════════════════════════════════════════════════════════════════════════════════ |
| 87 | + 🚀 GitHub Trending Repositories - Weekly 📊 |
| 88 | + 🌟 Discover the hottest projects on GitHub |
| 89 | +════════════════════════════════════════════════════════════════════════════════ |
| 90 | + |
| 91 | +┌─ 1. 📦 microsoft/TypeScript |
| 92 | +├─ 🔷 TypeScript |
| 93 | +├─ 🔥 95,234 stars (+234 today) |
| 94 | +└─ 📝 TypeScript is a superset of JavaScript that compiles to clean JavaScript... |
| 95 | + 💡 Type '1' to view README |
| 96 | +──────────────────────────────────────────────────────────── |
| 97 | + |
| 98 | +┌─ 2. 📦 facebook/react |
| 99 | +├─ 🟨 JavaScript |
| 100 | +├─ 🔥 201,456 stars (+456 today) |
| 101 | +└─ 📝 A declarative, efficient, and flexible JavaScript library for building... |
| 102 | + 💡 Type '2' to view README |
| 103 | + |
| 104 | +════════════════════════════════════════════════════════════════════════════════ |
| 105 | + 📊 Found 25 trending repositories • Happy coding! 🎉 |
| 106 | +════════════════════════════════════════════════════════════════════════════════ |
| 107 | + |
| 108 | +╔══════════════════════════════════════════════════════════╗ |
| 109 | +║ 🧭 Navigation Menu ║ |
| 110 | +╠══════════════════════════════════════════════════════════╣ |
| 111 | +║ 📖 Enter a number (1-25) to view README ║ |
| 112 | +║ 📋 Enter 'list' or 'l' to show repositories again ║ |
| 113 | +║ 🚪 Enter 'quit' or 'q' to exit ║ |
| 114 | +╚══════════════════════════════════════════════════════════╝ |
| 115 | + |
| 116 | +👉 Your choice: 1 |
| 117 | + |
| 118 | +================================================================================ |
| 119 | +📦 Repository Details |
| 120 | +================================================================================ |
| 121 | +📦 Name: microsoft/TypeScript |
| 122 | +🔗 URL: https://github.com/microsoft/TypeScript |
| 123 | +🏷️ Language: TypeScript |
| 124 | +⭐ Stars: 95234 (234 today) |
| 125 | +📝 Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript... |
| 126 | + |
| 127 | +📖 Fetching README... |
| 128 | + |
| 129 | +-------------------------------------------------------------------------------- |
| 130 | +📖 README |
| 131 | +-------------------------------------------------------------------------------- |
| 132 | +# TypeScript |
| 133 | + |
| 134 | +TypeScript is a language for application-scale JavaScript... |
| 135 | +[README content continues...] |
| 136 | + |
| 137 | +📖 Press Enter to continue... |
| 138 | +``` |
| 139 | + |
| 140 | +## 📁 Project Structure |
| 141 | + |
| 142 | +``` |
| 143 | +github-trending-cli/ |
| 144 | +├── github_trending/ |
| 145 | +│ ├── __init__.py # Package initialization |
| 146 | +│ ├── cli.py # Main CLI interface and argument parsing |
| 147 | +│ ├── scraper.py # GitHub trending page scraper |
| 148 | +│ └── display.py # Output formatting and display logic |
| 149 | +├── requirements.txt # Python dependencies |
| 150 | +├── setup.py # Package setup configuration |
| 151 | +└── README.md # This file |
| 152 | +``` |
| 153 | + |
| 154 | +## 🏗️ Architecture |
| 155 | + |
| 156 | +The project follows a clean, modular architecture: |
| 157 | + |
| 158 | +### `scraper.py` - GitHubTrendingScraper |
| 159 | +- Handles HTTP requests to GitHub trending page |
| 160 | +- Parses HTML content using BeautifulSoup |
| 161 | +- Extracts repository information (name, stars, language, etc.) |
| 162 | +- Fetches README content from repositories |
| 163 | + |
| 164 | +### `display.py` - DisplayManager |
| 165 | +- Manages all terminal output formatting |
| 166 | +- Handles repository list display |
| 167 | +- Provides README pagination for long content |
| 168 | +- Responsive terminal width detection |
| 169 | + |
| 170 | +### `cli.py` - GitHubTrendingCLI |
| 171 | +- Command-line argument parsing |
| 172 | +- Interactive navigation loop |
| 173 | +- Coordinates between scraper and display components |
| 174 | +- Error handling and user input validation |
| 175 | + |
| 176 | +## 🔧 Dependencies |
| 177 | + |
| 178 | +- **requests** (≥2.28.0) - HTTP requests to GitHub |
| 179 | +- **beautifulsoup4** (≥4.11.0) - HTML parsing |
| 180 | +- **lxml** (≥4.9.0) - Fast XML/HTML parser backend |
| 181 | + |
| 182 | +## 🎯 Usage Examples |
| 183 | + |
| 184 | +### View Today's Trending |
| 185 | +```bash |
| 186 | +github-trending |
| 187 | +``` |
| 188 | + |
| 189 | +### View Weekly Trending |
| 190 | +```bash |
| 191 | +github-trending --range weekly |
| 192 | +``` |
| 193 | + |
| 194 | +### View Monthly Trending |
| 195 | +```bash |
| 196 | +github-trending -r monthly |
| 197 | +``` |
| 198 | + |
| 199 | +## 🤝 Contributing |
| 200 | + |
| 201 | +1. Fork the repository |
| 202 | +2. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 203 | +3. Commit your changes (`git commit -m 'Add some amazing feature'`) |
| 204 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 205 | +5. Open a Pull Request |
| 206 | + |
| 207 | +## 📝 License |
| 208 | + |
| 209 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 210 | + |
| 211 | +## 🐛 Troubleshooting |
| 212 | + |
| 213 | +### Common Issues |
| 214 | + |
| 215 | +**Issue**: `ModuleNotFoundError: No module named 'github_trending'` |
| 216 | +**Solution**: Make sure you've installed the package with `pip install -e .` |
| 217 | + |
| 218 | +**Issue**: `requests.exceptions.ConnectionError` |
| 219 | +**Solution**: Check your internet connection and GitHub's availability |
| 220 | + |
| 221 | +**Issue**: Empty repository list |
| 222 | +**Solution**: GitHub might be rate-limiting requests. Wait a few minutes and try again. |
| 223 | + |
| 224 | +### Getting Help |
| 225 | + |
| 226 | +If you encounter any issues: |
| 227 | + |
| 228 | +1. Check the [Issues](https://github.com/your-username/github-trending-cli/issues) page |
| 229 | +2. Create a new issue with detailed information about the problem |
| 230 | +3. Include your Python version and operating system |
| 231 | + |
| 232 | +## 🌟 Acknowledgments |
| 233 | + |
| 234 | +- GitHub for providing the trending repositories page |
| 235 | +- The Python community for excellent libraries like requests and BeautifulSoup |
| 236 | +- All the amazing open-source projects that inspire us daily |
| 237 | + |
| 238 | +--- |
| 239 | + |
| 240 | +**Happy exploring! 🚀** |
0 commit comments