A command-line tool for syncing GitHub repositories from ITCPR Cloud to your local machine. Manage your repositories with secure device-based authentication and automated synchronization.
- 🔐 Device-based authentication with ITCPR Cloud
- 🆕 Create new repositories in the organization
- 📦 Automatic repository synchronization
- 🔄 Manual or continuous sync modes
- 🚀 Background service daemon (auto-start on boot)
- 💾 Local SQLite database for metadata tracking
- 🔒 Secure token storage using OS keyring
- 🛡️ Safe git operations with conflict detection
pip install itcprOr use pip3 or python3 -m pip if needed.
To install from source for development or contribution:
git clone https://github.com/ITCPR/cloud-cli.git
cd cloud-cli
pip install -e .Or use pip3 or python3 -m pip if needed.
To remove the CLI tool:
pip uninstall itcprNote: 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
# Remove configuration and data
rm -rf ~/.itcpr
# Remove stored tokens from 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- Python 3.10+
- Git (system installation)
- Access to api.itcpr.org (API) and cloud.itcpr.org (frontend)
Important: Before using the CLI, you must:
- Visit cloud.itcpr.org
- Connect your GitHub account
- Ensure your repositories are assigned to your device
Once your GitHub account is connected and repositories are assigned, you can proceed with the CLI login.
Authenticate your device with ITCPR Cloud:
itcpr loginNote: Make sure you've connected your GitHub account at cloud.itcpr.org before logging in.
This will:
- Open your browser to the device login page
- Display a device code
- Wait for approval
- Store credentials securely
View your assigned repositories:
itcpr statusSee all repositories assigned to your device:
itcpr reposClone a repository to your local machine:
itcpr clone paperport-itcprOr specify a custom path:
itcpr clone paperport-itcpr --path ~/projects/paperportCreate a new repository in the current folder using the project template:
itcpr initThis will:
- Create a new repository in the organization (using current directory name)
- Use
ITCPR/project-templateas the template - Fetch and copy template files to current directory
- Add you as an admin collaborator
- Initialize git repository
- Set up remote origin
- Create an initial commit with template files
With options:
# Custom repository name (creates private repo by default)
itcpr init --name my-new-repo
# With description
itcpr init --name my-repo --description "My awesome project"
# Create public repository (default is private)
itcpr init --public
# Initialize and push immediately
itcpr init --pushNote:
- If the repository name already exists in the organization, you'll be prompted to choose a different name.
- Template files from
ITCPR/project-templateare automatically copied to your directory. Existing files are preserved (not overwritten).
Sync all cloned repositories:
itcpr syncRun continuous sync (watches for changes):
itcpr sync --watchWith custom interval:
itcpr sync --watch --interval 120 # Sync every 2 minutesNote: Watch mode runs in the foreground and will block your terminal. Press Ctrl+C to stop.
For background operation, use the service commands (see below).
Run sync as a background service that starts automatically:
# Start service in background
itcpr service start
# Start with custom interval
itcpr service start --interval 120 # Sync every 2 minutes
# Check service status
itcpr service status
# View service logs
itcpr service logs
# Stop service
itcpr service stopInstall as System Service (Auto-start on boot):
# Install service (Linux - requires sudo)
sudo itcpr service install
# Install with custom interval
sudo itcpr service install --interval 120
# On macOS (no sudo needed)
itcpr service install
# On Windows (may require admin)
itcpr service installAfter installation:
- Linux (systemd):
sudo systemctl enable itcpr && sudo systemctl start itcpr - macOS (launchd):
launchctl load ~/Library/LaunchAgents/org.itcpr.sync.plist - Windows (Task Scheduler): The service will start automatically on user logon. To start immediately:
schtasks /Run /TN "ITCPR Sync Service"
Clear stored credentials:
itcpr logoutStarts the device authentication flow. Opens your browser to the device login page at cloud.itcpr.org/device and polls the API for approval.
Prerequisite: Ensure your GitHub account is connected at cloud.itcpr.org before logging in.
Revokes device token and clears local metadata.
Shows:
- Logged-in user information
- Device ID
- Your repositories
- Local repositories with sync status
Lists all repositories assigned to this device with their clone status.
Clones a repository from GitHub using short-lived installation tokens.
Options:
--path, -p: Custom local path for the repository
Removes a repository from local tracking (unregisters it). This does NOT delete:
- The repository from GitHub
- The local files on your machine
It only removes the repository from the local tracking database, so it will no longer appear in itcpr status or itcpr repos and won't be synced.
Example:
# Remove a repository from local tracking
itcpr remove my-repoNote: The local files remain on your system. You can delete them manually if needed.
Creates a new repository in the organization and initializes it in the current folder using the ITCPR/project-template template. The repository name defaults to the current directory name, or you can specify a custom name.
Options:
--name, -n: Repository name (defaults to current directory name)--description, -d: Repository description--public: Create a public repository (default: private)--push: Push initial commit to remote immediately
What it does:
- Creates a new repository in the organization from
ITCPR/project-templatetemplate via GitHub API - Fetches the template repository (
ITCPR/project-template) - Copies template files to current directory (preserves existing files)
- Adds you (the device owner) as an admin collaborator
- Initializes git repository if not already initialized
- Sets up remote origin with authentication
- Creates an initial commit with template files
- Optionally pushes to remote if
--pushis used
Template Behavior:
- The repository is created from the
ITCPR/project-templatetemplate repository - Template files are automatically copied to your current directory
- Existing files in the directory are preserved (not overwritten)
- The
.gitdirectory from the template is excluded
Example:
# Create repo with current directory name (private by default)
cd my-project
itcpr init
# Create repo with custom name
itcpr init --name awesome-project --description "My awesome project"
# Create public repo and push immediately
itcpr init --public --pushError handling:
- If the repository name already exists, you'll see: "Repository 'name' already exists in the organization. Please choose a different name."
- If your GitHub account is not connected, you'll be prompted to connect it first.
Synchronizes all cloned repositories. By default, performs a one-time sync.
Options:
--watch, -w: Run continuous sync loop (watches for changes)--interval, -i: Sync interval in seconds (watch mode only, default: 60)
Per-Repository Configuration (itcpr.yml):
You can configure per-repository sync behavior by creating an itcpr.yml file in the repository root:
sync:
enabled: true # Enable/disable sync for this repo (default: true)
auto_commit: true # Auto-commit uncommitted local changes (default: true)
auto_push: true # Auto-push local commits to remote (default: true)
branch: main # Optional: specific branch to sync
ignore: # Optional: patterns to ignore
- "*.log"
- "temp/"Note: auto_commit and auto_push are independent settings:
auto_commit: Automatically commits uncommitted changes in your working directoryauto_push: Automatically pushes local commits to the remote repository- If both are enabled (default), the tool will commit uncommitted changes and then push them automatically
- You can set
auto_commit: true, auto_push: falseto commit locally without pushing - If
itcpr.ymldoesn't exist, the tool uses default values (all enabled). The configuration file is optional.
Manage the sync service as a background daemon.
Commands:
start: Start the service in backgroundstop: Stop the running servicestatus: Show service status and informationlogs: View service logsinstall: Install as system service (auto-start on boot)uninstall: Remove system service
Options:
--interval, -i: Sync interval in seconds (default: 60)--foreground, -f: Run in foreground (don't daemonize)--user: User to run service as (for system service installation)
Examples:
# Start service in background
itcpr service start
# Start with custom interval
itcpr service start --interval 300 # 5 minutes
# Check if service is running
itcpr service status
# View recent logs
itcpr service logs
# Install to start on boot (Linux)
sudo itcpr service install
# Install to start on boot (macOS)
itcpr service install
# Install to start on boot (Windows - may require admin)
itcpr service install
# Uninstall system service
itcpr service uninstallService Features:
- Runs as background daemon (cross-platform)
- Automatic restart on failure (when installed as system service)
- Logs to
~/.itcpr/itcpr-service.log(or%USERPROFILE%\.itcpr\itcpr-service.logon Windows) - PID file management
- System service support:
- Linux: systemd service
- macOS: launchd agent
- Windows: Task Scheduler task
- Device requests an authentication code from the backend
- User approves the device in browser at
cloud.itcpr.org/device - Device token is stored securely in OS keyring
- Token is used for all subsequent API requests
The sync process follows these steps:
- Fetches latest changes from the remote repository
- Detects uncommitted local changes
- Automatically commits local changes (if enabled)
- Pulls remote changes with rebase
- Pushes local commits (if enabled and permitted)
- Aborts on merge conflicts (requires manual resolution)
- 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
The CLI stores configuration and data in ~/.itcpr/:
- Configuration:
~/.itcpr/config.toml- Global settings - Repository Database:
~/.itcpr/repos.db- SQLite database for repository metadata
Each repository can have its own itcpr.yml file in the repository root to control sync behavior:
sync:
enabled: true # Enable/disable sync for this repo
auto_commit: true # Automatically commit local changes
auto_push: true # Automatically push local commits
branch: main # Optional: sync specific branch
ignore: [] # Optional: file patterns to ignoreExample: Disable auto-push for a repository
sync:
auto_push: falseExample: Disable sync entirely for a repository
sync:
enabled: falseThe CLI includes a built-in mock mode for testing and development when the API is unavailable.
When the API at api.itcpr.org is unavailable, the CLI automatically falls back to mock API responses:
- If the backend returns 404 or is unreachable, mock responses are used automatically
- You'll see a warning: "
⚠️ Backend unavailable, using mock mode for testing"
You can also enable mock mode explicitly:
# Using environment variable
export ITCPR_MOCK_MODE=true
itcpr login
# Or set in config file (~/.itcpr/config.toml)
# mock_mode = trueMock Features:
- Auto-approves device login after 2 seconds
- Provides sample user and repository data
- Generates mock GitHub tokens
- All commands work in mock mode for testing purposes
Run itcpr login to authenticate your device. Make sure you've connected your GitHub account at cloud.itcpr.org first. If the backend is unavailable, mock mode will activate automatically for testing.
The repository must be assigned to your device in ITCPR Cloud. Make sure you've:
- Connected your GitHub account at cloud.itcpr.org
- Assigned the repository to your device in the ITCPR Cloud dashboard
If the issue persists, contact an administrator.
When running itcpr init, if you see this error, it means a repository with that name already exists in the organization. Choose a different name:
itcpr init --name different-nameThe init command requires your GitHub account to be connected. Make sure you've:
- Visited cloud.itcpr.org
- Connected your GitHub account
- Then run
itcpr initagain
If a merge conflict is detected during sync:
- Resolve conflicts manually in the repository
- Commit the resolution
- Run
itcpr syncagain
Ensure Git is installed and available in your PATH:
git --versionIf Git is not installed, install it using your system's package manager.
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 kdewalletOn macOS and Windows, the keyring should work out of the box.
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
# Install in development mode
pip install -e .
# Run CLI
itcpr --helpContributions are welcome! Please ensure your code follows the project's style guidelines and includes appropriate tests.
MIT License - see LICENSE file for details.
For issues, questions, or feature requests, please contact ITCPR support or open an issue on GitHub.