CLI commands

Every gize command: what it generates, when to reach for it, and the flags it takes. The CLI follows the verb–subcommand shape defined in ADR-012.

Global flags

These apply to every generating command (gize new and gize make …). Generation is safe by default: nothing is overwritten unless you ask.

--dry-runPrint the planned file operations (create / skip / update) and write nothing.
--forceOverwrite files that already exist; without it, existing files are skipped.

Commands

gize new <name>Available

Scaffolds a new project into a directory named <name>: a compiling, servable app in seconds.

  • Writes Cargo.toml, gize.toml, .env.example, .gitignore and the full src/ layout (app, config, database, middleware, shared, router.rs, state.rs, main.rs).
  • By default also generates a built-in users resource (model, full CRUD and a migration with an is_admin flag) already wired into app/mod.rs and gize.toml.
  • Pass --no-user to scaffold the bare skeleton without the users resource.
  • Choose the database with --database postgres (default), sqlite or mysql; add --openapi for a spec + /docs UI, and --api-version 1 to mount every route under /api/v1.
  • Pass --ws to scaffold a WebSocket module (src/app/ws/) with a typed echo endpoint at /ws.
Example $ gize new shop --database mysql --api-version 1
gize make app <name>Available

Creates an application module and wires it into the project.

  • Generates the nine module files (mod, model, dto, repository, service, handler, routes, error, tests) with a placeholder route.
  • Registers mod <name>; and .merge(<name>::routes()) in src/app/mod.rs and adds the module to gize.toml. All of this is idempotent, so re-running is a no-op.
Example $ gize make app products
gize make model <Name> field:Type …Available

Generates a model struct and its CREATE TABLE migration from inline field definitions.

  • model.rs is an sqlx::FromRow struct; an id: Uuid primary key and created_at / updated_at timestamps are added for you.
  • The table and module name are the pluralized snake_case of the model (User → users).
Example $ gize make model User name:String email:String
gize make crud <Name> field:Type …Available

The headline command: a complete, wired vertical slice for a resource.

  • Generates model, dto, repository (SQLx), service, handler (Axum), routes, a typed error, tests and the migration.
  • Registers the module in app/mod.rs and gize.toml, exposing working GET/POST/PUT/DELETE endpoints backed by the database.
Example $ gize make crud Product name:String price:i32 active:bool
gize make migration [name]Available

Creates a blank, timestamped SQL migration to fill in by hand.

  • The escape hatch for changes the model-driven generator does not cover: indexes, constraints, data backfills, column changes.
  • Model-driven CREATE TABLE files come from make model / make crud instead.
Example $ gize make migration add_index_to_users
gize make adminAvailable

Generates a standalone React + TypeScript admin SPA (Vite) for every resource in the manifest.

  • A dark-theme, Django-inspired dashboard: a changelist with search, per-field filters, pagination and bulk actions, plus a slide-over drawer for create/edit with foreign-key selects.
  • A separate, deployable artifact under admin/ that talks to the API with the JWT via a Vite dev proxy, and is not coupled to the backend build (ADR-006).
Example $ gize make admin
gize migrate [--status]Available

Applies pending SQL migrations from migrations/*.sql against DATABASE_URL.

  • Uses the SQLx migrator, which records applied versions in _sqlx_migrations, ordered and idempotent. There is no risky runtime auto-migration.
  • Pass --status to list applied [x] versus pending [ ] migrations instead of applying them.
Example $ gize migrate --status
gize createadminAvailable

Creates the first admin user in the database: Gize's createsuperuser.

  • Interactive by default (prompts for email, name and a hidden, confirmed password); non-interactive for CI with --email/--name and the password read from --password-env, never a raw argument.
  • Hashes the password with Argon2id in the format the generated login verifies, sets is_admin, rejects a duplicate email, and works against Postgres, SQLite or MySQL (ADR-017).
Example $ gize createadmin --email admin@example.com --name Admin --password-env GIZE_ADMIN_PASSWORD
gize serveAvailable

Runs the generated application, and (when an admin exists) its admin dev server alongside it.

  • Reads DATABASE_URL and PORT (default 8080) from the environment.
  • When the project has a generated admin, it also starts the admin dev server: it detects a package manager (pnpm, npm or yarn), installs deps on first run, prints both URLs, and stops both on Ctrl-C.
  • Select the mode with --api-only, --admin-only or --with-admin.
Example $ gize serve --api-only
gize syncAvailable

Reconciles the project from gize.toml: regenerates missing pieces and reports drift.

  • Dry-run first and drift-aware: it never clobbers hand edits without --force. Add a [[module]] to gize.toml and sync scaffolds and wires it (ADR-009).
Example $ gize sync
gize doctorAvailable

Sanity-checks your environment and project.

  • Reports cargo / rustfmt availability, whether you are inside a Gize project (gize.toml), and whether DATABASE_URL is set.
Example $ gize doctor
gize fmtAvailable

Formats the project with rustfmt, a thin wrapper around cargo fmt --all.

  • Runs across the whole workspace so generated and hand-written code stay consistent.
Example $ gize fmt
gize checkAvailable

Lints the project with clippy, denying warnings.

  • Wraps cargo clippy --all-targets -- -D warnings, the same quality gate CI enforces.
Example $ gize check

Safe by default: existing files are skipped unless you pass --force, and --dry-run previews the full plan without writing anything. Registry edits to app/mod.rs and gize.toml are idempotent.