Command Line Interface
A comprehensive command-line tool for managing your Flux Relay messaging platform from the terminal.
Introduction
╔═══════════════════════════════════════════════════════╗ ║ ║ ║ ███████╗██╗ ██╗ ██╗██╗ ██╗ ║ ║ ██╔════╝██║ ██║ ██║╚██╗██╔╝ ║ ║ █████╗ ██║ ██║ ██║ ╚███╔╝ ║ ║ ██╔══╝ ██║ ██║ ██║ ██╔██╗ ║ ║ ██║ ███████╗╚██████╔╝██╔╝ ██╗ ║ ║ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ║ ║ ─ ║ ║ ██████╗ ███████╗██╗ █████╗ ██╗ ██╗ ║ ║ ██╔══██╗██╔════╝██║ ██╔══██╗╚██╗ ██╔╝ ║ ║ ██████╔╝█████╗ ██║ ███████║ ╚████╔╝ ║ ║ ██╔══██╗██╔══╝ ██║ ██╔══██║ ╚██╔╝ ║ ║ ██║ ██║███████╗███████╗██║ ██║ ██║ ║ ║ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ║ ║ ║ ║ Command Line Interface v1.0.0 ║ ╚═══════════════════════════════════════════════════════╝
Flux Relay CLI is a powerful command-line tool for managing your Flux Relay messaging platform. It provides a comprehensive interface for database operations, nameserver management, and SQL query execution. Built with Go and featuring an interactive SQL shell similar to Turso, the CLI enables developers to efficiently manage their messaging infrastructure from the terminal.
The CLI follows a hierarchical structure: Projects → Servers → Nameservers, allowing you to organize and manage your messaging platform resources with context-aware commands.
Key Features
- OAuth 2.0 Device Authorization Grant: Secure authentication flow
- Interactive SQL Shell: Turso-like interface for SQL operations
- Project Management: List and select projects
- Server Management: Manage servers within projects
- Nameserver Management: Create and manage databases
- Headless Mode: Support for WSL, SSH, and CI/CD environments
Installation
┌─────────────────────────────────────────┐ │ INSTALLATION │ │ ═══════════════════════════════════════ │ │ │ │ Ready to get started? Let's install! │ └─────────────────────────────────────────┘
Prerequisites
Before installing Flux Relay CLI, ensure you have:
- Go 1.21+ (for building from source)
- Git (for cloning the repository)
- Internet connection (for authentication and API calls)
Install from Source
git clone https://github.com/postacksol/flux-relay-cli.git
cd flux-relay-cli
go build -o flux-relay .
sudo mv flux-relay /usr/local/bin/Verify Installation
flux-relay --versionAuthentication
┌─────────────────────────────────────────┐ │ AUTHENTICATION │ │ ═══════════════════════════════════════ │ │ │ │ Secure access to your platform │ └─────────────────────────────────────────┘
Flux Relay CLI uses OAuth 2.0 Device Authorization Grant flow for secure authentication. This allows you to authenticate without exposing your credentials in the terminal.
Login
To authenticate with Flux Relay, run:
flux-relay loginThis will:
- Generate a device code and user code
- Open your browser automatically to complete authentication
- Wait for you to authorize the device
- Save your access token securely to
~/.flux-relay/config.json
Manual Token Configuration
If you have an access token, you can set it manually:
flux-relay config set token "YOUR_TOKEN_HERE"Logout
To log out and remove your stored token:
flux-relay logoutSecurity Note: Tokens are stored with secure file permissions (0600) in ~/.flux-relay/config.json, ensuring only you can read your credentials.
Upgrading
┌─────────────────────────────────────────┐ │ UPGRADING │ │ ═══════════════════════════════════════ │ │ │ │ Keep your CLI up to date! │ └─────────────────────────────────────────┘
To upgrade Flux Relay CLI to the latest version, pull the latest changes from the repository and rebuild:
cd flux-relay-cli
git pull origin main
go build -o flux-relay .
sudo mv flux-relay /usr/local/bin/After upgrading, verify the new version:
flux-relay --versionHelp
┌─────────────────────────────────────────┐ │ HELP │ │ ═══════════════════════════════════════ │ │ │ │ Need assistance? We've got you! │ └─────────────────────────────────────────┘
Get help with any command by using the --help flag:
flux-relay --helpGet help for a specific command:
flux-relay login --helpHeadless Mode
┌─────────────────────────────────────────┐ │ HEADLESS MODE │ │ ═══════════════════════════════════════ │ │ │ │ No browser? No problem! │ └─────────────────────────────────────────┘
Headless mode is designed for environments where a browser cannot be opened automatically, such as WSL, SSH sessions, or CI/CD pipelines.
Using Headless Mode
Run login with the --headless flag:
flux-relay login --headlessThis will:
- Display a device code and verification URL
- Provide instructions to manually visit the URL
- Show how to copy the token after authentication
Note: In headless mode, you'll need to manually copy the access token from the success page and run flux-relay config set token "YOUR_TOKEN" to complete authentication.
Commands
┌─────────────────────────────────────────┐ │ COMMANDS │ │ ═══════════════════════════════════════ │ │ │ │ Master the CLI with these commands │ └─────────────────────────────────────────┘
Authentication Commands
flux-relay loginAuthenticate with Flux Relay using OAuth 2.0 Device Authorization Grant. Opens your browser automatically to complete authentication.
flux-relay login --headlessAuthenticate without opening a browser. Perfect for WSL, SSH sessions, and CI/CD pipelines. You'll receive a device code to enter manually.
flux-relay logoutLog out and remove your stored authentication token from ~/.flux-relay/config.json.
flux-relay config set token <token>Manually set your access token if you have one. Useful for CI/CD or when copying tokens from other sources.
Project Commands
flux-relay pr listList all projects in your account
flux-relay pr <name-or-id>Select a project to work with
Server Commands
flux-relay server listList all servers in the selected project
flux-relay server <name-or-id>Select a server
flux-relay server shell <name-or-id>Open interactive SQL shell for a server
Nameserver Commands
flux-relay ns listList all nameservers in the selected server
flux-relay ns create <name>Create a new nameserver
flux-relay ns initialize <name-or-id>Initialize default messaging platform tables
flux-relay ns shell <name-or-id>Open interactive SQL shell for a nameserver
SQL Commands
flux-relay sql "SELECT * FROM table"Execute a one-off SQL query
Configuration Commands
flux-relay config set token <token>Set access token manually