CLI Commands Reference
Lila Framework provides powerful CLI tools to speed up development. All commands
follow the pattern
lila-{command}
Model Generator
Lila features a powerful model builder that scaffolds SQLAlchemy models inheriting from BaseModel.
Running the command without parameters starts the Interactive Wizard, allowing you to configure primary keys, soft delete logic, timestamps, and define custom columns right from the console.
# 1. Start the interactive console wizard
lila-model create
# 2. Create a default model skeleton non-interactively
lila-model create --name Product
# 3. Create a model with a custom database table name
lila-model create --name Product --table custom_products
# 4. Force interactive mode even when providing parameters
lila-model create --name User --interactive
# 5. List all active model files inside app/models/
lila-model list-models
Interactive Wizard Features
The interactive prompt guides you through standard configuration choices:
- Table Name: Automatically infers pluralized snake_case of the model name, or takes a custom name.
- Primary Key: Generates an optimized primary key (e.g.
id) configured with database indexes (index=True) for high query performance. - Soft Delete: Sets up
_delete_logic = Trueand appends an active column. Calling delete on models automatically acts as soft delete. - Timestamps: Prompts you to add
created_atandupdated_attimezone/TIMESTAMP fields. - Custom Column Loop: Add columns dynamically: asks for name, type (String, Integer, Float, Text, Boolean), length (for Strings), nullability, uniqueness, and optional defaults.
Scaffold Generator
Generate complete CRUD functionality from existing models.
# Generate scaffold from model lila-scaffold-crud --model Product # Custom route name lila-scaffold-crud --model Product --name products
Migrations
Run database migrations to create tables from models.
# Run migrations lila-migrations migrate # Refresh (drop and recreate all tables) lila-migrations migrate --refresh
Authentication
Generate authentication system with login, register, and password recovery.
# Generate auth system lila-auth main
Admin Panel
Create admin users and admin panel.
# Create admin user lila-create-admin --password mypassword # Create admin panel lila-create-panel-admin --password mypassword
Minify Assets
Minify CSS and JavaScript files in-place for production.
# Minify all CSS and JS files lila-minify
Optimize Assets (Ahead-of-Time)
Create a production-ready manifest mapping, convert images to WebP, and generate parallel
.min.js and .min.css files without modifying your original files. The
public() Jinja helper will automatically load these optimized assets.
# Optimize all Images, CSS, and JS lila-optimize
Security Utilities
Generate a new secure SECRET_KEY for
your .env file.
# Replace SECRET_KEY in .env with a new randomly generated token lila-secret-key
SEO Generators
Generate sitemap.xml and robots.txt files automatically based
on your application's routes.
# Generate sitemap.xml in the public folder lila-seo sitemap --domain https://mywebsite.com # Generate robots.txt in the public folder lila-seo robots --domain https://mywebsite.com
Docker Database Isolation
Manage isolated database containers (MySQL and PostgreSQL) for your local development and staging environments. This keeps the database engine isolated while the Python application runs as a native host service.
# Start MySQL database container lila-docker start mysql # Start PostgreSQL database container lila-docker start postgres # Start all database containers (MySQL and PostgreSQL) lila-docker start all # Stop and remove MySQL database container lila-docker stop mysql # Stop and remove PostgreSQL database container lila-docker stop postgres # Stop and tear down all database containers lila-docker stop all # List active database containers status (runs automatically when calling lila-docker with no subcommand) lila-docker ps # or lila-docker # Conectar a MySQL usando las credenciales y BD del .env del proyecto lila-docker mysql # o usando el alias corto: lila-docker db # Conectar como usuario root usando el password root del .env lila-docker mysql --root # Especificar/sobrescribir usuario, contraseña o BD si es necesario lila-docker mysql -u root -p mi_password -d mi_base_de_datos # Conectar a la consola interactiva de Redis (redis-cli) en el contenedor lila-docker redis # o usando el alias corto: lila-docker redis-cli # Mostrar uso de disco de Docker (imágenes, volúmenes, caché) lila-docker df # o alias corto: lila-docker disk # Limpiar volúmenes huérfanos, imágenes dangling y caché de BuildKit lila-docker prune # o alias corto: lila-docker clean # Sin confirmación (ideal para scripts de despliegue): lila-docker clean -f
Development Server
Start the local development server (uvicorn) instantly without writing python main.py.
# Run development server with default dev services (MySQL and Redis containers up) lila-dev # Skip starting the MySQL database container lila-dev --no-mysql # or --without-mysql # Skip starting the Redis database container lila-dev --no-redis # or --without-redis
Background Task Worker
Start the background task runner to process tasks asynchronously enqueued in Redis (e.g. mailer, database write-backs).
# Start background task worker process lila-worker start