Skip to main content

Interactive CLI for managing o2switch/cPanel domains, subdomains, and DNS records.

Project description

o2switch-cli

CLI interactif pour gerer domaines, sous-domaines cPanel et enregistrements DNS sur un hebergement o2switch/cPanel.

Version actuelle: 0.1.0

Installation

./install.sh

The installer:

  • Creates a local virtual environment
  • Installs the CLI and dependencies
  • Prompts for cPanel credentials (stored in ~/.config/o2switch-cli/.env)
  • Publishes o2switch-cli to ~/.local/bin
  • Installs bash completion

After install, reload your shell:

source ~/.bashrc && hash -r

Non-interactive install

./install.sh --cpanel-host saule.o2switch.net --cpanel-user myuser --cpanel-token mytoken

Development install

./install.sh --dev

Skip setup wizard

./install.sh --skip-setup
o2switch-cli config init  # configure later

Uninstall

./uninstall.sh
./uninstall.sh --purge-venv --purge-config --purge-state

Configuration

Credentials are stored globally in ~/.config/o2switch-cli/.env and loaded automatically.

# Show current config and where it's loaded from
o2switch-cli config show

# Show config file paths (active, global, local)
o2switch-cli config path

# Re-run setup wizard
o2switch-cli config init

# Test API access
o2switch-cli config test

Config file locations

  1. Local .env in current directory (takes precedence)
  2. Global ~/.config/o2switch-cli/.env (default)

Environment variables

You can also set credentials via environment variables:

export O2SWITCH_CLI_CPANEL_HOST=saule.o2switch.net
export O2SWITCH_CLI_CPANEL_USER=myuser
export O2SWITCH_CLI_CPANEL_TOKEN=mytoken

Getting a cPanel API token

  1. Log into cPanel
  2. Go to Security > Manage API Tokens
  3. Create a new token with appropriate permissions
  4. Copy the token (it's only shown once)

Usage

o2switch-cli              # Interactive mode (if TTY)
o2switch-cli --help       # Show all commands

DNS Records

# Point a hostname to an IP (create or update A record)
o2switch-cli dns upsert --host staging.example.com --ip 203.0.113.25

# With explicit zone and custom TTL
o2switch-cli dns upsert --zone example.com --host staging --ip 203.0.113.25 --ttl 600

# Search DNS records
o2switch-cli dns search example

# Delete an A record
o2switch-cli dns delete --host staging.example.com

# Verify DNS resolution
o2switch-cli dns verify --host staging.example.com --ip 203.0.113.25

# Dry run (show what would change without applying)
o2switch-cli dns upsert --host staging.example.com --ip 203.0.113.25 --dry-run

Domains

o2switch-cli domains list
o2switch-cli domains list --page 2 --page-size 10

Subdomains

o2switch-cli subdomains create --root example.com --label staging --ip 203.0.113.25
o2switch-cli subdomains list
o2switch-cli subdomains delete --fqdn staging.example.com

Output formats

o2switch-cli domains list --json
o2switch-cli config show --json

Interactive mode includes loading spinners, real-time search suggestions, and paginated navigation.

Versioning

o2switch-cli suit Semantic Versioning.

  • format: MAJOR.MINOR.PATCH
  • version actuelle: 0.1.0
  • tags de release: vMAJOR.MINOR.PATCH
  • changelog: CHANGELOG.md
  • politique detaillee: VERSIONING.md

Regles de bump:

  • MAJOR: rupture de compatibilite sur la CLI, la sortie JSON stable, les comportements de mutation, ou les variables/configs publiques
  • MINOR: nouvelles commandes, nouvelles options retro-compatibles, nouveaux workflows ou nouveaux champs JSON optionnels
  • PATCH: corrections retro-compatibles, docs, tests, durcissement interne sans rupture contractuelle

Tant que le projet reste en 0.x, un bump MINOR peut encore embarquer des changements cassants. Les correctifs PATCH doivent rester retro-compatibles.

Source de verite:

Avant une release, mettre a jour le changelog, verifier o2switch-cli --version, puis tagger le commit avec vX.Y.Z.

Development

.venv/bin/ruff check .
.venv/bin/ruff format .
.venv/bin/pytest

Specs

Le pack de specifications projet est dans docs/specs/README.md.

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

o2switch_cli-0.1.0.tar.gz (45.1 kB view details)

Uploaded Source

Built Distribution

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

o2switch_cli-0.1.0-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file o2switch_cli-0.1.0.tar.gz.

File metadata

  • Download URL: o2switch_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 45.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for o2switch_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 30de0f4399c93b3624d88c11920fb3307e915f8df8c75ad95377f4dc2d34baf9
MD5 03a68c0aa1cefe3757ef6caac6eca736
BLAKE2b-256 2bd6f581074e00f4ffdd0d3228b3cfbf2cfb4075ea48c0c255d2e6601c2047c1

See more details on using hashes here.

File details

Details for the file o2switch_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: o2switch_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 44.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for o2switch_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94aaac8892e62802e0b784e9c5ad2c644215e06fe5a046bac35066d09afe3b54
MD5 1503960a3ef2c614f20c7c3283d4191d
BLAKE2b-256 41ac682d2693c6b39454e86f649a33cb2e02c65f4fc166934b1b0116c67b5289

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