Typr CLI
The Typr CLI generates type-safe code from your configuration.
Commandsβ
typr # Generate code (default)
typr init # Create typr.yaml
typr validate # Check configuration
That's it. Three commands.
Generate Codeβ
Running typr without arguments reads typr.yaml and generates code:
typr
Connecting to postgres... β
Connecting to mariadb... β
Loading api/openapi.yaml... β
Generating shared types...
FirstName, LastName, Email, CustomerId, OrderId
Generating postgres...
42 tables, 156 files
Generating mariadb...
18 tables, 67 files
Generating api...
12 endpoints, 34 files
Done. 257 files in ./generated
Optionsβ
typr --config other.yaml # Use different config file
typr --watch # Regenerate on changes
typr --verbose # Show detailed output
Initialize Projectβ
typr init
Creates a typr.yaml with sensible defaults. You'll be prompted for:
- Language (Java/Kotlin/Scala)
- Output directory
- First data source connection
Validateβ
typr validate
Checks your configuration without generating code:
Validating typr.yaml...
Sources:
β postgres: Connected (PostgreSQL 16.1)
β mariadb: Connected (MariaDB 11.2)
β api: Loaded (3 endpoints, 12 schemas)
Types:
β FirstName: 6 matches, compatible (String)
β Email: 8 matches, compatible (String)
β PhoneNumber: No matches in 'mariadb'
Configuration valid.
Configuration Fileβ
See Configuration Reference for the full typr.yaml format.
Minimal example:
sources:
postgres:
type: postgresql
host: localhost
database: myapp
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
output:
path: ./generated
package: com.myapp
language: java