Skip to content

DavidHayter/rex-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ¦– 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 ⭐

About

πŸ¦– Rex β€” A Swiss Army Knife CLI for DevOps Engineers

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages