Skip to main content

๐Ÿฆ– Rex โ€” A Swiss Army Knife CLI for DevOps Engineers

Project description

๐Ÿฆ– Rex

A Swiss Army Knife CLI for DevOps Engineers

PyPI version Python License: MIT Tests

Encrypt secrets, lint configs, generate passwords, inspect certificates โ€” all from your terminal.

Installation ยท Quick Start ยท Commands ยท Contributing


โšก Installation

# From PyPI
pip install rex-cli

# With JMESPath query support
pip install rex-cli[query]

# From source
git clone https://github.com/DavidHayter/rex-cli.git
cd rex-cli
pip install -e ".[dev]"

Verify installation:

rex version

๐Ÿš€ Quick Start

# Encrypt a secret
rex encrypt enc "my-database-password" -p

# Beautify a JSON file
rex json beautify --file config.json --output pretty.json

# Lint your Kubernetes YAML
rex yaml lint deployment.yaml

# Generate a secure password
rex password generate --length 32

# Explain a cron expression
rex cron explain "*/5 9-17 * * 1-5"

# Hash a file
rex hash generate --file backup.tar.gz --all

# Check SSL certificate expiry
rex cert expiry example.com

# Scan open ports
rex net port 192.168.1.1 22,80,443,8080

๐Ÿ“– Commands

๐Ÿ” rex encrypt โ€” Encryption & Decryption

Encrypt and decrypt data using industry-standard algorithms with password-based key derivation (PBKDF2, 480k iterations).

# Encrypt with AES-256-GCM (default)
rex encrypt enc "sensitive data" -p
> Enter password: ****

# Encrypt with ChaCha20-Poly1305
rex encrypt enc "sensitive data" -p --algo chacha20-poly1305

# Encrypt a file
rex encrypt enc -p --file secrets.env --output secrets.enc

# Decrypt
rex encrypt dec "eyJhbGci..." -p

# List supported algorithms
rex encrypt algorithms
Algorithm Description
aes-256-gcm Default. NIST standard, authenticated encryption
chacha20-poly1305 Fast on devices without AES hardware support
fernet High-level symmetric encryption (AES-128-CBC + HMAC)

๐Ÿ“‹ rex json โ€” JSON Operations

# Beautify
rex json beautify '{"name":"rex","version":1}' --indent 4

# Beautify from file and save
rex json beautify --file raw.json --output pretty.json

# Minify
rex json minify --file config.json

# Validate
rex json validate --file package.json

# Query with JMESPath (requires: pip install rex-cli[query])
cat data.json | rex json query "users[?age > `30`].name"

๐Ÿ“„ rex yaml โ€” YAML Operations

# Lint a YAML file
rex yaml lint deployment.yaml

# Strict mode (warns on tabs, trailing whitespace)
rex yaml lint values.yaml --strict

# Convert YAML to JSON
rex yaml to-json --file values.yaml --output values.json

# Convert JSON to YAML
rex yaml to-yaml --file config.json --output config.yaml

# Validate YAML syntax
rex yaml validate "key: value"

๐Ÿ”‘ rex password โ€” Password Generation

# Generate a 24-char password (default)
rex password generate

# Custom length, multiple passwords
rex password generate --length 48 --count 5

# No symbols
rex password generate --length 16 --no-symbols

# Exclude ambiguous characters
rex password generate --exclude "0OlI1"

# Generate a passphrase
rex password passphrase --words 6 --separator "-"

# Capitalized passphrase
rex password passphrase --words 5 --capitalize --separator "."

โฐ rex cron โ€” Cron Expressions

# Explain a cron expression
rex cron explain "30 2 * * 0"

# Show all presets
rex cron presets

# Use a preset
rex cron generate daily
rex cron generate backup-nightly
rex cron generate business-hours

# Build custom expression
rex cron generate --minute "*/15" --hour "9-17" --weekday "1-5"

DevOps-focused presets: health-check, backup-nightly, cleanup-weekly, log-rotation, cert-renewal, and more.


๐Ÿ”’ rex hash โ€” Hash Generation

# SHA-256 hash (default)
rex hash generate "hello world"

# All algorithms at once
rex hash generate "hello world" --all

# Hash a file
rex hash generate --file backup.tar.gz --algo sha512

# HMAC
rex hash hmac "message" --key "my-secret" --algo sha256

# Verify a hash
rex hash verify "hello" --expected "2cf24dba..."
Algorithm Output Length
md5 128-bit
sha1 160-bit
sha256 256-bit
sha512 512-bit
blake2b 512-bit
blake2s 256-bit

๐Ÿ“ฆ rex base64 โ€” Base64 Operations

# Encode
rex base64 encode "hello world"

# Decode
rex base64 decode "aGVsbG8gd29ybGQ="

# URL-safe encoding
rex base64 encode "https://example.com?q=test" --url-safe

# File operations
rex base64 encode --file image.png --output image.b64
rex base64 decode --file image.b64 --output restored.png

# Pipe support
echo "secret" | rex base64 encode

๐ŸŽซ rex jwt โ€” JWT Token Inspection

# Decode a JWT
rex jwt decode "eyJhbGciOiJIUzI1NiIs..."

# Pipe from clipboard
pbpaste | rex jwt decode

# Shows:
# - Header (algorithm, type)
# - Payload (all claims)
# - Expiry status (VALID / EXPIRED)
# - Issued at, subject, issuer, audience

๐Ÿ†” rex uuid โ€” UUID Generation

# Generate UUID v4 (random)
rex uuid generate

# Multiple UUIDs
rex uuid generate --count 10

# UUID v1 (timestamp-based)
rex uuid generate --version 1

# UUID v5 (namespace + name)
rex uuid generate --version 5 --name "example.com"

# Uppercase
rex uuid generate --upper

๐Ÿ“œ rex cert โ€” SSL/TLS Certificate Inspection

# Full certificate details
rex cert inspect google.com

# Check expiry (great for monitoring scripts)
rex cert expiry google.com
rex cert expiry --warn 60 production-api.company.com

# Custom port
rex cert inspect mail.example.com --port 465

Exit codes for cert expiry (perfect for monitoring):

  • 0 โ€” Certificate is valid
  • 1 โ€” Certificate expiring soon (within --warn days)
  • 2 โ€” Certificate expired or connection failed

๐ŸŒ rex net โ€” Network Utilities

# DNS lookup
rex net dns example.com
rex net dns example.com --type MX
rex net dns example.com --type TXT

# Port scanning
rex net port 192.168.1.1 22,80,443
rex net port server.com 8000-8010

# Ping
rex net ping 8.8.8.8
rex net ping google.com --count 10

๐Ÿ”ง Pipe Support

Rex supports Unix pipes across all commands:

# Chain commands
echo '{"key":"value"}' | rex json beautify
cat config.yaml | rex yaml to-json
echo "secret" | rex base64 encode
echo "secret" | rex hash generate --all
pbpaste | rex jwt decode

๐Ÿงช Development

# Clone and install
git clone https://github.com/DavidHayter/rex-cli.git
cd rex-cli
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=rex --cov-report=html

# Lint
ruff check rex/
ruff format rex/

# Type check
mypy rex/

๐Ÿ“ฆ Project Structure

rex-cli/
โ”œโ”€โ”€ rex/
โ”‚   โ”œโ”€โ”€ __init__.py          # Version & metadata
โ”‚   โ”œโ”€โ”€ cli.py               # Main CLI entry point
โ”‚   โ””โ”€โ”€ commands/
โ”‚       โ”œโ”€โ”€ encrypt_cmd.py   # Encryption & decryption
โ”‚       โ”œโ”€โ”€ json_cmd.py      # JSON operations
โ”‚       โ”œโ”€โ”€ yaml_cmd.py      # YAML operations
โ”‚       โ”œโ”€โ”€ password_cmd.py  # Password generation
โ”‚       โ”œโ”€โ”€ cron_cmd.py      # Cron expressions
โ”‚       โ”œโ”€โ”€ hash_cmd.py      # Hash generation
โ”‚       โ”œโ”€โ”€ base64_cmd.py    # Base64 encode/decode
โ”‚       โ”œโ”€โ”€ jwt_cmd.py       # JWT inspection
โ”‚       โ”œโ”€โ”€ uuid_cmd.py      # UUID generation
โ”‚       โ”œโ”€โ”€ cert_cmd.py      # SSL/TLS inspection
โ”‚       โ””โ”€โ”€ network_cmd.py   # Network utilities
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_cli.py          # Test suite
โ”œโ”€โ”€ pyproject.toml            # Package configuration
โ”œโ”€โ”€ LICENSE                   # MIT License
โ”œโ”€โ”€ CHANGELOG.md              # Version history
โ””โ”€โ”€ README.md                 # This file

๐Ÿ—บ๏ธ Roadmap

  • rex k8s โ€” Kubernetes context switcher & resource inspector
  • rex docker โ€” Docker image size analyzer & cleanup
  • rex env โ€” .env file encryption & diff
  • rex tf โ€” Terraform state inspector
  • rex log โ€” Log parser with pattern matching
  • Plugin system for community extensions

๐Ÿ“ License

MIT โ€” see LICENSE for details.


Built with ๐Ÿฆ– by Merthan

If Rex saved you some time, consider giving it a โญ

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

rex_cli-1.0.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

rex_cli-1.0.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rex_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rex_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 080939aea20bbe91bfad33d41ca8962b584d553722410c6022b995016ccb5434
MD5 dc51033c882fbc82b6ae449bf6538648
BLAKE2b-256 ce4b8949f16cee40d155280b1b85efdeaca5078484eeadba7b1b137e9e0db0ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for rex_cli-1.0.0.tar.gz:

Publisher: publish.yml on DavidHayter/rex-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: rex_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rex_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 175da537ac1a0354b965a3e00455d15f153d7eea898f9cbeeab0a1ab3557fd25
MD5 3f4187db29beb45cebe42614b435d47f
BLAKE2b-256 dd66d5a08b29e1ba3d765558ad4d312544775b8855905c755ad77a5cbfed1411

See more details on using hashes here.

Provenance

The following attestation bundles were made for rex_cli-1.0.0-py3-none-any.whl:

Publisher: publish.yml on DavidHayter/rex-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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