A powerful, modern command-line interface for managing cppq (C++ Queue) Redis queues with rich formatting, comprehensive logging, and flexible configuration options.
- Modern CLI Framework: Built with Click for intuitive command structure
- Rich Output Formatting: Beautiful tables, JSON, and pretty-print output options
- Type Safety: Full type hints and Pydantic models for data validation
- Comprehensive Error Handling: User-friendly error messages with detailed logging
- Flexible Configuration: Support for config files, environment variables, and command-line options
- Colorized Output: Enhanced readability with Rich formatting
- Debug Mode: Detailed logging for troubleshooting
- Clone the repository and navigate to the CLI directory:
cd cppq/cli- Install dependencies:
pip install -r requirements.txt- Make the CLI executable (optional):
chmod +x main.pyThe CLI supports multiple configuration methods with the following precedence:
- Command-line arguments (highest priority)
- Environment variables
- Configuration file
- Default values (lowest priority)
Copy .env.example to .env and customize:
cp .env.example .envAvailable environment variables:
REDIS_URI: Redis connection URI (default:redis://localhost)CPPQ_OUTPUT_FORMAT: Default output format (table/json/pretty)CPPQ_DEBUG: Enable debug logging (true/false)CPPQ_LOG_FILE: Path to log file (optional)
Create a configuration file:
python main.py config --createThis creates a config file at ~/.config/cppq/config.json:
{
"redis_uri": "redis://localhost",
"output_format": "table",
"debug": false,
"log_file": null
}Show help:
python main.py --helpList all queues:
python main.py queuesGet queue statistics:
python main.py stats myqueueList tasks in a queue:
python main.py list myqueue pending
python main.py list myqueue active --limit 10Get task details:
python main.py task myqueue 123e4567-e89b-12d3-a456-426614174000Pause/unpause a queue:
python main.py pause myqueue
python main.py unpause myqueueUse different output formats with the --format option:
Table format (default):
python main.py queues --format tableJSON format:
python main.py queues --format jsonPretty-print format:
python main.py queues --format prettyEnable debug logging:
python main.py --debug queuesUse custom Redis URI:
python main.py --redis-uri redis://myserver:6379/0 queuesUse custom config file:
python main.py --config /path/to/config.json queuesList all queues with their priorities and pause status.
python main.py queuesDisplay statistics for a specific queue.
python main.py stats myqueueList task UUIDs in a specific queue state.
States: pending, scheduled, active, completed, failed
python main.py list myqueue pending
python main.py list myqueue active --limit 20Get detailed information about a specific task.
python main.py task myqueue 123e4567-e89b-12d3-a456-426614174000Pause a queue to prevent task processing.
python main.py pause myqueueUnpause a queue to resume task processing.
python main.py unpause myqueueManage CLI configuration.
# Show current configuration
python main.py config
# Create default configuration file
python main.py config --createShow version information.
python main.py version# Check all queues
python main.py queues
# Get detailed stats for problematic queue
python main.py stats problem-queue
# List failed tasks
python main.py list problem-queue failed --format json | jq '.'# Enable debug mode and check task details
python main.py --debug task myqueue 123e4567-e89b-12d3-a456-426614174000# Export all pending tasks to JSON
python main.py list myqueue pending --format json > pending-tasks.json
# Pause multiple queues
for queue in queue1 queue2 queue3; do
python main.py pause $queue
doneLogs are written to:
- Console (warnings and above by default, all levels in debug mode)
- File (if configured via
CPPQ_LOG_FILEor config file)
Enable debug logging:
python main.py --debug <command>Configure log file:
export CPPQ_LOG_FILE=/var/log/cppq-cli.logIf you can't connect to Redis:
- Check Redis is running:
redis-cli ping - Verify connection URI:
python main.py --redis-uri redis://localhost:6379 queues - Enable debug mode:
python main.py --debug queues
If you get permission errors:
- Check Redis ACL/password requirements
- Use authenticated URI:
redis://username:password@host:port
For better performance with large queues:
- Use
--limitflag when listing tasks - Use JSON output format for programmatic processing
- Consider using Redis connection pooling
main.py: Main CLI entry point with command definitionsconfig.py: Configuration managementlogger.py: Logging setup and utilitiesrequirements.txt: Python dependencies
- Add command function to
main.py - Use
@cli.command()decorator - Add proper type hints and error handling
- Update this README
# Run tests (when implemented)
pytest tests/See the main project LICENSE file.