class AmberCLI::Documentation::GenerationSystem

Overview

Code Generation System

The generate command creates application components following V2 patterns.

Available Generators

Model Generator

Creates a model with associated migration and spec:

amber generate model User name:string email:string

Controller Generator

Creates a controller with views and spec using Amber::Testing:

amber generate controller Posts index show

Scaffold Generator

Creates a complete CRUD resource with schema-based validation:

amber generate scaffold Post title:string body:text published:bool

Migration Generator

Creates a database migration file:

amber generate migration AddStatusToUsers

Job Generator

Creates a background job class extending Amber::Jobs::Job:

amber generate job SendNotification --queue=mailers --max-retries=5

Mailer Generator

Creates a mailer class extending Amber::Mailer::Base:

amber generate mailer User --actions=welcome,notify

Schema Generator

Creates a schema definition extending Amber::Schema::Definition:

amber generate schema User name:string email:string:required age:int32

Channel Generator

Creates a WebSocket channel extending Amber::WebSockets::Channel:

amber generate channel Chat

API Generator

Creates an API-only controller with model and schema:

amber generate api Product name:string price:float

Auth Generator

Creates an authentication system with login and registration:

amber generate auth

Field Types

Available field types for model, scaffold, schema, and api generators:

Schema Field Format

Schema fields support a :required suffix:

amber generate schema User name:string:required email:email:required age:int32

Defined in:

amber_cli/documentation.cr