Skip to main content

Command-line interface for V2Hub VPN Subscription API client

Project description

V2Hub CLI - Command-Line Interface for VPN Subscription API

Beautiful, user-friendly command-line interface for V2Hub VPN Subscription API with optional admin commands.

Features

  • 🎨 Beautiful Output: Rich formatting with colors and tables
  • Fast & Intuitive: Simple commands for all operations
  • 🔧 Regular Commands: Full access to subscription management
  • 🔐 Admin Commands: Optional admin operations (requires v2hub-admin)
  • 📋 Multiple Formats: JSON, table, or minimal output
  • 🎯 Type Safe: Auto-completion support

Installation

Basic Installation

# Install CLI (includes v2hub automatically)
pip install v2hub-cli

With Admin Support

# Install CLI with admin commands
pip install v2hub-cli[admin]

Usage

After installation, the v2hub command is available:

v2hub --help

Basic Commands

# Show version
v2hub version

# List all subscriptions
v2hub list

# Create a subscription
v2hub create "my-vpn"

# Get subscription details
v2hub get <token>

# Add sources to subscription
v2hub add-sources <token> -s vless://server1 vmess://server2

# Get subscription config URL
v2hub config <token>

# Delete subscription
v2hub delete <token>

Admin Commands

Admin commands are available only if v2hub-admin is installed:

# Show admin help
v2hub admin --help

# Show admin version
v2hub admin version

# List all subscriptions in the system (admin)
v2hub admin list-all

# Get any subscription (bypass ownership)
v2hub admin get <token>

# Delete any subscription (admin privilege)
v2hub admin delete <token>

# Get system statistics
v2hub admin stats

Environment Variables

Configure the CLI using environment variables:

# Required
export V2HUB_API_URL="https://api.example.com"
export V2HUB_API_TOKEN="your-api-token"

# For admin commands (optional)
export V2HUB_ADMIN_SECRET="your-hmac-secret"

# Then use commands
v2hub list
v2hub admin list-all  # if v2hub-admin is installed

Configuration File

Create ~/.v2hub/config.json:

{
  "api_url": "https://api.example.com",
  "api_token": "your-api-token",
  "admin_secret": "your-hmac-secret"
}

Examples

Create and Configure Subscription

# Create subscription
v2hub create "work-vpn" --comment "Office VPN servers"

# Add sources
v2hub add-sources <token> -s\
  vless://server1.example.com:443 \
  vmess://server2.example.com:443

# View sources
v2hub sources <token>

# Get config URL
v2hub config <token>

List and Filter

# List all your subscriptions
v2hub list

# List with JSON output
v2hub list --format json

# Get specific subscription
v2hub get <token>

Update Subscription

# Update name
v2hub update <token> --name "new-name"

# Update comment
v2hub update <token> --comment "Updated description"

# Replace all sources
v2hub replace-sources <token> vless://new-server

Admin Operations

# List all subscriptions (requires admin)
v2hub admin list-all

# Get any subscription (requires admin)
v2hub admin get <any-token>

# Delete any subscription (requires admin)
v2hub admin delete <any-token>

# System statistics (requires admin)
v2hub admin stats

Output Formats

The CLI supports multiple output formats:

# Table format (default, rich formatting)
v2hub list

# JSON format (for scripting)
v2hub list --format json

# Minimal format (just values)
v2hub list --format minimal

Command Reference

Regular Commands

Command Description
v2hub version Show version information
v2hub list List your subscriptions
v2hub create <name> Create new subscription
v2hub get <token> Get subscription details
v2hub update <token> Update subscription
v2hub delete <token> Delete subscription
v2hub add-sources <token> <uri...> Add sources
v2hub remove-sources <token> <uri...> Remove sources
v2hub replace-sources <token> <uri...> Replace all sources
v2hub sources <token> List sources
v2hub config <token> Get subscription config
v2hub refresh <token> Refresh subscription

Admin Commands (Optional)

Command Description
v2hub admin --help Show admin commands help
v2hub admin version Show admin module version
v2hub admin list-all List all subscriptions (admin)
v2hub admin get <token> Get any subscription (admin)
v2hub admin delete <token> Delete any subscription (admin)
v2hub admin stats System statistics (admin)

Exit Codes

  • 0 - Success
  • 1 - General error
  • 2 - Invalid command or arguments
  • 3 - Authentication error
  • 4 - Not found error
  • 5 - API error

Development

# Install in development mode
pip install -e ".[dev]"

# Install with admin support
pip install -e ".[admin,dev]"

# Run tests
pytest

# Type checking
mypy src/

Optional Dependencies

The CLI has a modular design:

  • Base: v2hub (required, installed automatically)
  • Admin: v2hub-admin (optional, install with pip install v2hub-cli[admin])

If admin module is not installed, admin commands are automatically hidden and disabled.

Requirements

  • v2hub >= 1.0.0 (required, installed automatically)
  • v2hub-admin >= 1.0.0 (optional, for admin commands)
  • Python >= 3.9

Graceful Admin Fallback

When v2hub-admin is not installed:

$ v2hub admin --help
Error: Admin commands require the 'v2hub-admin' package.
Install it with: pip install v2hub-admin

$ v2hub --help
# Shows only regular commands, admin section is hidden

License

MIT License - see LICENSE file for details.

Author

nestt

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

v2hub_cli-1.0.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

v2hub_cli-1.0.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file v2hub_cli-1.0.0.tar.gz.

File metadata

  • Download URL: v2hub_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for v2hub_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 18a09db657291b07cb8b65c778368a8b0a17c8f30db49f80bf72ff21118e2fc2
MD5 2f525ab17fd3afaa5d2f30d17b5f1c4a
BLAKE2b-256 1ac2327660733ac8c4df633e52343d734bd9387b759f02c799e5f0220a8cff8a

See more details on using hashes here.

File details

Details for the file v2hub_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: v2hub_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for v2hub_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0505b430c9c8bf628531c23e83d5578653ec14fa8f2f219d6f1df9dff35d04
MD5 e32feb516436c791970d00ff2b6923e3
BLAKE2b-256 8b9d8f02b6736317e14a96a67376d9ff48c6176e3ec753843b85376cdcda6241

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