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.

Model Builder Commands
# 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 = True and appends an active column. Calling delete on models automatically acts as soft delete.
  • Timestamps: Prompts you to add created_at and updated_at timezone/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.

cli.scaffold_crud

# 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.

cli.migrations

# 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.

cli.auth

# Generate auth system
lila-auth main

Admin Panel

Create admin users and admin panel.

cli.create_admin

# Create admin user
lila-create-admin --password mypassword

# Create admin panel
lila-create-panel-admin --password mypassword

Security Utilities

Generate a new secure SECRET_KEY for your .env file.

cli.secret_key

# 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.

cli.seo

# 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.

cli.docker
# Pre-flight diagnostic & port check
lila-docker check

# Start dev stack (MySQL + Redis)
lila-docker start

# Start complete production stack (MySQL + Redis + App + Nginx)
lila-docker start prod

# Start specific containers
lila-docker start mysql
lila-docker start redis
lila-docker start postgres

# Live resource usage & memory monitoring (shows ~70MB MySQL RAM)
lila-docker stats

# Zero-downtime automated VPS deploy (git pull, build, migrate, restart)
lila-docker deploy

# Restart containers
lila-docker restart
lila-docker restart app

# Stop containers
lila-docker stop
lila-docker stop mysql
lila-docker stop app

# Full teardown (containers and networks)
lila-docker down

# List active containers status
lila-docker ps
# or
lila-docker

# Tail logs
lila-docker logs
lila-docker logs mysql
lila-docker logs nginx

# Connect to MySQL using credentials from .env
lila-docker mysql
lila-docker db # short alias
lila-docker mysql --root

# Connect to Redis CLI inside container
lila-docker redis
lila-docker redis-cli

# Display Docker disk space usage
lila-docker df
lila-docker disk

# Clean up orphaned volumes, dangling images, and BuildKit cache
lila-docker prune
lila-docker clean -f

Development Server

Start the local development server (uvicorn) instantly without writing python main.py.

cli.dev

# 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).

cli.worker

# Start background task worker process
lila-worker start