Skip to main content

CLI tool for syncing GitHub repositories from ITCPR Cloud

Project description

ITCPR CLI

A production-ready CLI tool for syncing GitHub repositories from ITCPR Cloud to your local machine.

Features

  • 🔐 Device-based authentication with cloud.itcpr.org
  • 📦 Automatic repository synchronization
  • 🔄 Manual or continuous sync modes
  • 💾 Local SQLite database for metadata tracking
  • 🔒 Secure token storage using OS keyring
  • 🛡️ Safe git operations with conflict detection

Installation

From PyPI (Recommended)

pip install itcpr
# OR
pip3 install itcpr
# OR
python3 -m pip install itcpr

From Source

If you want to install from source or contribute:

git clone <repository-url>
cd cloud-cli
pip install -e .
# OR
pip3 install -e .
# OR
python3 -m pip install -e .

Uninstall

To remove the CLI tool:

pip uninstall itcpr

Note: This will remove the CLI tool but will not delete:

  • Configuration files (~/.itcpr/config.toml)
  • Local repository database (~/.itcpr/repos.db)
  • Stored device tokens (in OS keyring)

To completely remove all data:

# Uninstall the package
pip uninstall itcpr
# OR
pip3 uninstall itcpr
# OR
python3 -m pip uninstall itcpr

# Remove configuration and data
rm -rf ~/.itcpr

# Remove stored tokens (OS keyring)
# On macOS: Use Keychain Access app to remove "itcpr" entries
# On Linux: Use your keyring manager (e.g., seahorse, kwallet)
# On Windows: Use Credential Manager

Requirements

  • Python 3.10+
  • Git (system installation)
  • Access to cloud.itcpr.org

Quick Start

1. Login

Authenticate your device with ITCPR Cloud:

itcpr login

This will:

  • Open your browser to the device login page
  • Display a device code
  • Wait for approval
  • Store credentials securely

2. Check Status

View your assigned repositories:

itcpr status

3. List Repositories

See all repositories assigned to your device:

itcpr repos

4. Clone a Repository

Clone a repository to your local machine:

itcpr clone paperport-itcpr

Or specify a custom path:

itcpr clone paperport-itcpr --path ~/projects/paperport

5. Sync Repositories

Sync all cloned repositories:

itcpr sync

Run continuous sync (watches for changes):

itcpr sync --watch

With custom interval:

itcpr sync --watch --interval 120  # Sync every 2 minutes

6. Logout

Clear stored credentials:

itcpr logout

Commands

itcpr login

Starts device authentication flow. Opens browser to cloud.itcpr.org/device and polls for approval.

itcpr logout

Revokes device token and clears local metadata.

itcpr status

Shows:

  • Logged-in user information
  • Device ID
  • Assigned repositories
  • Local repositories with sync status

itcpr repos

Lists all repositories assigned to this device with their clone status.

itcpr clone <repo>

Clones a repository from GitHub using short-lived installation tokens.

Options:

  • --path, -p: Custom local path for the repository

itcpr sync

One-shot synchronization of all cloned repositories.

Options:

  • --watch, -w: Run continuous sync loop
  • --interval, -i: Sync interval in seconds (watch mode only, default: 60)

How It Works

Authentication

  1. Device requests authentication code from backend
  2. User approves device in browser at cloud.itcpr.org/device
  3. Device token is stored securely in OS keyring
  4. Token is used for all API requests

Repository Sync

  1. Fetches latest changes from remote
  2. Detects uncommitted local changes
  3. Commits local changes if any
  4. Pulls remote changes with rebase
  5. Pushes local commits if permitted
  6. Aborts on merge conflicts (requires manual resolution)

Security

  • No Personal Access Tokens: Only uses backend-issued short-lived GitHub installation tokens
  • Device Tokens: Revocable device authentication
  • OS Keyring: Credentials stored securely using system keyring
  • Safe Git Operations: Never force-pushes, detects conflicts

Configuration

Configuration is stored in ~/.itcpr/config.toml.

Repository metadata is stored in ~/.itcpr/repos.db (SQLite).

Troubleshooting

"Not logged in" error

Run itcpr login to authenticate your device.

"Repository not assigned" error

The repository must be assigned to your device in ITCPR Cloud. Contact an administrator.

Merge conflicts

If a merge conflict is detected during sync:

  1. Resolve conflicts manually in the repository
  2. Commit the resolution
  3. Run itcpr sync again

Git command not found

Ensure Git is installed and available in your PATH:

git --version

Token storage issues

On Linux, you may need to install a keyring backend:

# For GNOME
sudo apt-get install python3-keyring

# For KDE
sudo apt-get install python3-keyring kdewallet

Development

Project Structure

cloud-cli/
├── itcpr/
│   ├── __init__.py      # Package initialization
│   ├── cli.py           # CLI commands
│   ├── auth.py          # Authentication
│   ├── api.py           # API client
│   ├── gitops.py        # Git operations
│   ├── sync.py          # Sync logic
│   ├── config.py        # Configuration
│   ├── storage.py       # SQLite storage
│   └── utils.py         # Utilities
├── setup.py             # Setup script
├── pyproject.toml       # Project metadata
└── README.md            # This file

Running Tests

# Install in development mode
pip install -e .
# OR
pip3 install -e .
# OR
python3 -m pip install -e .

# Run CLI
itcpr --help

API Endpoints

The CLI communicates with these backend endpoints:

  • POST /api/device/start - Start device authentication
  • GET /api/device/poll - Poll for authentication approval
  • POST /api/device/revoke - Revoke device token
  • GET /api/agent/me - Get device/user information
  • GET /api/agent/repos - Get assigned repositories
  • POST /api/agent/token - Get GitHub installation token

License

MIT License

Support

For issues and questions, contact ITCPR support or open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itcpr-2.0.6.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itcpr-2.0.6-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file itcpr-2.0.6.tar.gz.

File metadata

  • Download URL: itcpr-2.0.6.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for itcpr-2.0.6.tar.gz
Algorithm Hash digest
SHA256 a3e9f4479c0e6d327ced15eab3ed0912e1d0a509e33914cdeaeeac5229e748ad
MD5 4790c048c81aec5f4d2f6be6d0755182
BLAKE2b-256 e9e1571afb0953070420ccf5ff851602d8dd37d558bda7f88ddee350b8d69da7

See more details on using hashes here.

File details

Details for the file itcpr-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: itcpr-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for itcpr-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1717ff9efca3e0694e912ae354511e24ea388c81722b15967df75985644390e6
MD5 750b47f5e8fe857e1db30901b7e62781
BLAKE2b-256 a989c23f871bed9e0c4e3ba76b0dbc44a0a9c2357c63b9bb66efdd44ce205b68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page