handling
A Cargo extension that adds cargo load and cargo unload commands for managing binary packages from custom registries and GitHub repositories.
Features
- Direct GitHub installation: Install binaries directly from GitHub repos
- Version control: Support for tags, branches, and commits
- Custom registries: Resolve package names from your own registry
- Automatic authentication: Auto-retries with
GITHUB_TOKENwhen needed - Zero external dependencies: Pure Rust implementation
Installation
Or build locally:
Usage
Load/install a package
From GitHub:
This will install the binary from https://github.com/example/cli.git
With version/ref:
From registry:
With authentication:
# Or set GITHUB_TOKEN env var
Install specific binary:
Force reinstall:
Use locked dependencies:
Unload/uninstall a package
This wraps behind the scenes:
Uninstall specific binary:
How It Works
Registry Resolution
Default registry: github.com/handling-rs/registry
Registry structure (registry.toml):
[]
= "https://github.com/example/cli.git"
[]
= "https://github.com/example/tool.git"
Custom registry:
--registry example→github.com/example/handling-registry--registry example/custom→github.com/example/custom
Fallback to crates.io
When you install a package by name (without /):
-
Default behavior (no
--registryflag):- First tries to find the package in the default handling registry
- If not found, automatically falls back to crates.io
- Notifies you which source was used
-
Custom registry (with
--registryflag):- Only searches the specified registry
- If not found, fails with an error (no fallback)
- This ensures you know exactly which source is being used
Examples:
# Tries handling registry first, falls back to crates.io if not found
# Only searches custom registry, fails if not found
Ref Parsing
When you specify @version:
@vX.Y.Zor@X.Y.Z→ Git tag@<7+ hex chars>→ Git commit- Anything else → Git branch
Authentication
- First attempts request without token
- If
401or403response:- If
--tokenprovided: uses that token - Otherwise: auto-retries with
GITHUB_TOKENenv var
- If
- Token is injected into URL:
https://<TOKEN>@github.com/...
This works for both registry fetching (private registries) and git cloning (private repos).
Building Locally
Prerequisites:
- Rust 1.70+ (2021 edition)
Build:
Install:
Test:
Project Structure
src/
├── lib.rs # Entry point
├── bin/
│ ├── cargo-load.rs # Load binary
│ └── cargo-unload.rs # Unload binary
├── commands/
│ ├── load.rs # Load command logic
│ └── unload.rs # Unload command logic
└── core/
├── parser.rs # Spec & ref parsing
├── registry.rs # Registry resolution
├── git.rs # Git URL handling
└── http.rs # HTTP fetching
Examples
# Install from GitHub
# Install specific version
# Install from custom registry
# Install with authentication
# Install specific binary only
# Force reinstall
# Use locked dependencies
# Uninstall
# Uninstall specific binary