# 🚀 Interactive GitHub User Removal Script An intuitive, guided script that walks you through the process of removing users from GitHub repositories with a beautiful interactive interface. ## ✨ Features ### đŸŽ¯ Interactive Experience - **Beautiful Welcome Screen** with ASCII art - **Step-by-step Guided Process** - no command line arguments needed - **Smart Input Validation** with helpful error messages - **Confirmation Prompts** to prevent accidental operations - **Real-time Progress Updates** with visual progress bars ### đŸ›Ąī¸ Safety Features - **Dry Run Mode** (recommended first run) - preview changes without executing - **Multiple Confirmation Steps** for destructive operations - **Token Validation** before proceeding - **Pattern Preview** to show what repositories will match ### 🎨 User Interface - **Color-coded Output** for easy reading - **Emoji Icons** for visual clarity - **Formatted Headers** and sections - **Clear Success/Error Messages** ## 📋 Requirements - `bash` (version 4.0+) - `curl` - `jq` - Valid GitHub Personal Access Token with `repo` and `admin:org` permissions ## 🚀 Usage Simply run the script - no command line arguments needed: ```bash ./remove_user_guided.sh ``` The script will guide you through each step: ### 1. 🔑 GitHub Authentication ``` 🔑 GitHub Authentication ============================================================ Please provide your GitHub Personal Access Token: 💡 The token should have 'repo' and 'admin:org' permissions 💡 You can create one at: https://github.com/settings/tokens 🔐 Enter your GitHub token: [hidden input] ``` ### 2. 👤 Target Organization/User ``` 👤 Target Organization/User ============================================================ Enter the GitHub username or organization name: 💡 This is where we'll look for repositories 💡 Examples: 'mycompany', 'john-doe', 'my-organization' đŸĸ Organization/Username: ``` ### 3. đŸŽ¯ User to Remove ``` đŸŽ¯ User to Remove ============================================================ Enter the username you want to remove from repositories: 💡 This user will be removed as a collaborator from matching repositories 💡 They will lose access to private repositories (if applicable) 👤 Username to remove: ``` ### 4. 📁 Repository Filter ``` 📁 Repository Filter ============================================================ Enter a repository name pattern to filter repositories: 💡 Pattern examples: â€ĸ '*' - All repositories â€ĸ 'myproject-' - Repos starting with 'myproject-' â€ĸ '*api*' - Repos containing 'api' â€ĸ 'web-app' - Repos starting with 'web-app' 🔍 Repository pattern: ``` ### 5. âš™ī¸ Operation Options ``` âš™ī¸ Operation Options ============================================================ Choose your operation mode: 1) 🔍 Dry Run - Preview what would be done (Recommended) 2) 🚀 Execute - Perform the actual removal Select option (1 or 2): ``` ### 6. 📋 Final Summary ``` 📋 Operation Summary ============================================================ Configuration: đŸĸ Organization/User: myorg 👤 User to remove: olduser 🔍 Repository pattern: project-* âš™ī¸ Mode: Dry Run 📝 Logging: Standard Ready to proceed? (yes/no): ``` ## 🎭 Interactive Flow Example Here's what a complete session looks like: ``` ╔══════════════════════════════════════════════════════════╗ ║ ║ ║ 🚀 GitHub User Removal Tool 🚀 ║ ║ ║ ║ Remove users from repositories with ease! ║ ║ ║ ╚══════════════════════════════════════════════════════════╝ â„šī¸ Welcome to the Interactive GitHub User Removal Script! 🔑 GitHub Authentication ============================================================ [Token input and validation...] 👤 Target Organization/User ============================================================ [Organization selection...] đŸŽ¯ User to Remove ============================================================ [User selection with confirmation...] 📁 Repository Filter ============================================================ [Pattern selection with preview...] âš™ī¸ Operation Options ============================================================ [Mode selection...] 📋 Operation Summary ============================================================ [Final confirmation...] 🚀 Processing Repositories ============================================================ â„šī¸ Discovering repositories for myorg... ✅ Found 25 repositories â„šī¸ Filtering repositories by pattern 'project-*'... ✅ Found 8 repositories matching pattern 'project-*' â„šī¸ Processing repositories... Progress: [100%] 8/8 repositories processed [DRY RUN] Would remove olduser from myorg/project-api [DRY RUN] Would remove olduser from myorg/project-web 🎉 Operation Complete ============================================================ 📊 Statistics: 📁 Repositories scanned: 25 🔍 Repositories matching pattern: 8 👤 Repositories where user was collaborator: 2 ✅ Successful removals: 0 â„šī¸ Already removed: 0 ❌ Failed removals: 0 âš ī¸ This was a dry run - no actual changes were made 💡 To perform the actual removal, run the script again and select 'Execute' mode 🙏 Thank you for using the GitHub User Removal Tool! ``` ## đŸ›Ąī¸ Safety Features in Detail ### 1. **Token Validation** - Validates GitHub token before any operations - Shows authenticated username for confirmation - Provides clear error messages for invalid tokens ### 2. **Input Validation** - Validates username/organization formats - Checks repository pattern syntax - Provides helpful suggestions for corrections ### 3. **Confirmation Steps** - Confirms user to be removed - Confirms repository pattern understanding - Requires explicit "YES" for destructive operations ### 4. **Dry Run Mode (Recommended)** - Shows exactly what would be done - No actual changes made - Perfect for testing and verification ### 5. **Pattern Preview** - Shows what the pattern will match before execution - Examples: "This will match repositories starting with: project-" - Helps prevent unintended scope ## 🔧 Repository Patterns | Pattern | What it Matches | Examples | |---------|-----------------|----------| | `*` | All repositories | All repos in the org/user | | `bytelyst-` | Repos starting with 'bytelyst-' | `bytelyst-web`, `bytelyst-api`, `bytelyst-mobile` | | `*api*` | Repos containing 'api' | `web-api`, `user-api-v2`, `api-gateway` | | `web-*` | Repos starting with 'web-' | `web-frontend`, `web-backend`, `web-app` | | `*-service` | Repos ending with '-service' | `user-service`, `auth-service` | ## 🎨 Color Coding The script uses intuitive color coding: - đŸ”ĩ **Blue**: Informational messages and prompts - đŸŸĸ **Green**: Success messages and confirmations - 🟡 **Yellow**: Warnings and important notices - 🔴 **Red**: Errors and failures - đŸŸŖ **Purple**: Section headers - đŸŸĻ **Cyan**: Progress updates and statistics ## 🚨 Important Notes 1. **Always start with Dry Run mode** to preview changes 2. **Double-check the user to remove** - there's no undo! 3. **Verify repository patterns** match your intentions 4. **Ensure your token has sufficient permissions** 5. **Users will lose access to private repositories** immediately ## 💡 Tips for Best Experience 1. **Have your GitHub token ready** before starting 2. **Know the exact username** you want to remove 3. **Think about the repository pattern** beforehand 4. **Use Dry Run first** to verify everything looks correct 5. **Keep the terminal window** large enough for the interface ## 🔗 Quick Start Guide 1. **Prepare**: Get your GitHub token with proper permissions 2. **Run**: Execute `./remove_user_guided.sh` 3. **Follow**: The interactive prompts step by step 4. **Preview**: Always do a dry run first 5. **Execute**: Run again in execute mode if satisfied ## ⚡ Keyboard Shortcuts - `Ctrl+C`: Cancel operation at any time - `Enter`: Confirm current input - Arrow keys work in most terminals for command history ## 🆘 Need Help? The script provides comprehensive help at each step: - Clear explanations for each input - Examples for common patterns - Helpful error messages - Recovery suggestions --- **Ready to clean up your repositories? Just run `./remove_user_guided.sh` and let the script guide you!** 🚀