A CLI tool to manage GitHub repositories with interactive features
Project description
GitHub Repository Manager
A command-line tool to interactively manage GitHub repositories with powerful features.
Features
- Interactive terminal UI for managing repositories using arrow keys and spacebar
- Repository operations:
- Archive repositories
- Delete repositories
- Interactive action selection (choose between archive/delete after selecting repos)
- Pagination for large numbers of repositories
- Filter repositories by name pattern or visibility (public/private)
- Dry run mode to preview operations
- Confirmation step to prevent accidental operations
- Color-coded selection interface for easy navigation
Installation
Via pip (recommended)
pip install github-repository-manager
Install from source
- Clone this repository:
git clone https://github.com/conficiusa/github-repository-manager.git
cd github-repository-manager
- Install the package:
pip install -e .
Usage
Command Line Interface
After installation, you can run the tool directly using:
github-repository-manager
Or with command line arguments:
github-repository-manager --pattern "test-" --dry-run
Python Library
You can also use the package as a Python library in your code:
# Using the convenience function
from github_repo_manager import manage_repositories
# Manage repositories interactively
manage_repositories(
token="your-github-token", # Optional: will prompt if not provided
username="your-username", # Optional: will prompt if not provided
pattern="test-", # Optional: filter repos by name
visibility="private", # Optional: 'public' or 'private'
dry_run=True, # Optional: preview without changes
no_confirm=False, # Optional: skip confirmation
delay=1.0 # Optional: delay between operations
)
# Using the class directly for more control
from github_repo_manager import GitHubRepoManager
# Initialize the manager
deleter = GitHubRepoManager(token="your-github-token", username="your-username")
# Get repositories (optionally filtered)
repos = deleter.get_repositories(filter_pattern="test-", visibility="private")
# Manage repositories with interactive selection
deleter.manage_repositories(repos, dry_run=True, confirm=True, delay=1.0)
Authentication
The script will prompt you for:
- Your GitHub personal access token
- Your GitHub username
You can also provide these through:
- Command line arguments
- Environment variables (
GITHUB_TOKENandGITHUB_USERNAME)
Command Line Arguments
usage: github-repository-manager [-h] [--token TOKEN] [--username USERNAME]
[--pattern PATTERN]
[--visibility {public,private}] [--no-confirm]
[--dry-run] [--delay DELAY]
Manage GitHub repositories
options:
-h, --help show this help message and exit
--token TOKEN GitHub personal access token
--username USERNAME GitHub username
--pattern PATTERN Regex pattern to match repository names
--visibility {public,private}
Filter by visibility
--no-confirm Skip confirmation prompt
--dry-run Only show which repos would be affected
--delay DELAY Delay between operations in seconds
Interactive UI Instructions
The script provides an interactive terminal UI for managing repositories:
-
Repository Selection:
- Use ↑/↓ arrow keys to move between repositories
- Press SPACE to select/unselect a repository
- Use PgUp/PgDn to navigate between pages
- Press
ato select all repositories - Press
nto clear all selections - Press ENTER to confirm selection
- Press
qto quit without changes
-
Action Selection:
- After selecting repositories, choose between:
- Archive: Archive the selected repositories
- Delete: Delete the selected repositories
- Use ↑/↓ arrow keys to select action
- Press ENTER to confirm
- Press
qto cancel
- After selecting repositories, choose between:
-
Confirmation:
- Review the selected repositories and action
- Confirm with 'y' to proceed
- Any other key to cancel
Examples
- Basic usage (will prompt for repository selection and action):
github-repository-manager
- Manage only repositories matching a pattern:
github-repository-manager --pattern "test-"
- Manage only private repositories:
github-repository-manager --visibility private
- Dry run (preview only):
github-repository-manager --dry-run
- Skip interactive selection:
github-repository-manager --no-confirm
Creating a GitHub Personal Access Token
To use this script, you need a GitHub personal access token with appropriate scopes:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token" → "Generate new token (classic)"
- Give your token a name and select the required scopes:
reposcope for both archiving and deleting repositoriesdelete_reposcope if you plan to delete repositories
- Click "Generate token" and copy the token for use with this script
Development
To contribute to the development of this tool:
- Clone the repository
- Install in development mode:
pip install -e .
- Make your changes
- Submit a pull request
Publishing to PyPI
To publish this package to PyPI (for the maintainer):
# Install build tools
pip install build twine
# Build the package
python -m build
# Upload to PyPI (you'll need PyPI credentials)
twine upload dist/*
Security Note
Never share your personal access token. The token grants access to your repositories, so handle it with care.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file github_repository_manager-0.1.1.tar.gz.
File metadata
- Download URL: github_repository_manager-0.1.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0857213b25edf52ccbc8e923aac5b84f3261933a9be48f58e93dcc7424cf3c7a
|
|
| MD5 |
ceab3759d921a73c7737abf6d4f4a895
|
|
| BLAKE2b-256 |
7be34c33583ce87b8557b57d50ec2028062e309961de219ee6603b3af6f04eb4
|
File details
Details for the file github_repository_manager-0.1.1-py3-none-any.whl.
File metadata
- Download URL: github_repository_manager-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc565ca381486d723c1813a70952a7cb35c92bce264ca8337fbc38a0aa7fddae
|
|
| MD5 |
d66bb3f46ebd8c252a327d17797a73af
|
|
| BLAKE2b-256 |
13a321dda8f1ab432b56ed47fcf0c67e7152370ad9e03286c4804f03efbe6f98
|