CLI¶
REROUTE includes a command-line interface for scaffolding and managing your file-based routes.
Installation¶
The CLI is installed automatically with REROUTE:
Verify installation:
Quick Start¶
Create a New Project¶
Create a Route¶
This creates app/routes/user/page.py with boilerplate code.
Create a Nested Route¶
Creates app/routes/user/profile/page.py.
Available Commands¶
-
Create a new REROUTE project with FastAPI/Flask
-
Generate a new route file with HTTP methods
-
Generate full CRUD operations (Create, Read, Update, Delete)
-
Generate Pydantic models for data validation
CLI Options¶
Global options:
-V, --version- Show REROUTE version and exit--help- Show help message and exit
All commands also support --help to show command-specific help.
Examples¶
Initialize with FastAPI¶
Initialize with Flask¶
Create Multiple Routes¶
reroute create route --path /user --name User
reroute create route --path /product --name Product
reroute create route --path /order --name Order
Create with Custom Methods¶
Interactive Mode¶
The CLI features an interactive mode with auto-completion:
Navigate through options with arrow keys and select with Enter.
Configuration¶
CLI behavior can be customized via .rerouterc file:
Troubleshooting¶
Problem 1: Command not found: reroute¶
Error:
Solutions:
1. Install REROUTE: pip install reroute
2. Ensure pip bin directory is in PATH:
python -m reroute --version
Problem 2: Invalid value for '--path': Path cannot contain invalid character¶
Error:
Cause:
Trying to use :id syntax in path (not supported on Windows)
Solution: Use query parameters instead of path parameters in folder names:
# Wrong:
reroute create route --path /users/:id
# Correct:
reroute create route --path /users --name Users
# Then use query parameter: user_id: int = Query(...)
Problem 3: Not in a REROUTE project directory¶
Error:
Solution:
1. Initialize a project first: reroute init my-api
2. Navigate into the project: cd my-api
3. Then run other commands: reroute create route --path /users --name Users
Problem 4: Class already exists error¶
Error:
Cause: Trying to create a route with a class name that already exists
Solutions:
1. Use a different name: reroute create route --path /users --name UserRoutes
2. Delete the existing route file first
3. Use --methods to add methods to existing route
Problem 5: Generated code has incorrect imports¶
Symptom:
Generated code imports from fastapi instead of reroute.params
Solution: Update REROUTE to the latest version:
Templates were fixed in v0.1.4 to use cross-framework imports.
Learn More¶
- Command Reference - Detailed command documentation
- Scaffolding - Project structure and templates