Skip to content
loco
v1.0
★ 6.9k Get started

CLI reference

Loco ships two command-line surfaces:

BinaryCrateInstalled viaPurpose
locoloco-new (binary crate, not loco-rs)cargo install locoScaffolds a new app on disk. One subcommand: new.
cargo locogenerated into every app by loco new, backed by loco_rs::clibuilt with your appRuntime operations against your app: start the server, run migrations, generate code, run tasks, etc.

cargo loco has two main() implementations, selected by the with-db Cargo feature (src/cli.rs:712 when with-db is on, src/cli.rs:872 when it is off). The non-with-db build has no Db subcommand and no DB-backed generators (model/migration/scaffold). Both variants share the same top-level -e, --environment <ENV> global flag (default development).


1. loco new — the app generator

Source: loco-new/src/bin/main.rs:30-62.

1.1 Global flag

FlagTypeDefaultPurpose
-l, --log <LEVEL>LevelFilterERRORVerbosity of the generator’s own logging (main.rs:22-24)

1.2 new flags

FlagTypeDefaultPurpose
-p, --path <PATH>PathBuf.Local directory to generate into (main.rs:34-36)
-n, --name <NAME>Option<String>none — promptsApp name (main.rs:38-40)
--db <DB>wizard::DBOptionnone — promptsDB provider: sqlite | postgres | none (main.rs:42-44)
--bg <BG>wizard::BackgroundOptionnone — promptsBackground-worker mode: async | queue-redis | queue-postgres | queue-sqlite | blocking (main.rs:46-48)
--assets <ASSETS>wizard::AssetsOptionnone — promptsAsset serving: serverside | clientside | none (main.rs:50-52)
--embedded-assetsboolfalse — prompts (interactive, serverside only)Embed static assets into the binary (embedded_assets feature). Serverside only; combined with --assets clientside it is a hard error. Supplying it (or running fully flag-driven) skips the interactive prompt
-a, --allow-in-git-repoboolfalseSkip the “you’re inside a git repo, continue?” abort prompt (main.rs:54-56)
--os <OS>wizard::OSlinux on Unix, windows otherwiseGenerate a Unix- or Windows-optimized starter: windows | linux | macos (main.rs:58-60, DEFAULT_OS main.rs:64-67)

There is no -t/--template and no -v/--verbose flag. The Template enum exists internally and derives ValueEnum, but it is not wired to any CLI argument — template choice is interactive-only (§1.4).

If --db, --bg, and --assets are all supplied, the wizard skips every prompt except app name (wizard.rs:287-297); app name still prompts unless --name is also given.

1.3 Interactive prompts (when flags are omitted)

Source: loco-new/src/wizard.rs.

  1. App name? (default myapp) — non-empty, no leading digit, Unicode XID + -/_ (wizard.rs:201-267).
  2. “You are inside a git repository. Do you wish to continue?” — only if cwd is a git repo and --allow-in-git-repo was not passed; default No, aborts on decline (wizard.rs:227-240; main.rs:91-94).
  3. “What would you like to build?” — template select (wizard.rs:299-302).
  4. Conditional DB / background / assets follow-ups, depending on the chosen template.

1.4 Templates

Source: wizard.rs:12-27, branch logic wizard.rs:304-333.

Template (enum)Menu labelDB prompt?BG prompt?Assets
SaasServerSideRendering (default)“Saas App with server side rendering”yesyesforced Serverside
SaasClientSideRendering”Saas App with client side rendering”yesyesforced Clientside
RestApi”Rest API (with DB and user auth)“yesyesforced None
Lightweight”lightweight-service (minimal, only controllers and views)“no — forced Noneno — forced Asyncforced None
Advanced”Advanced”yesyesasks (only template that prompts for asset config)

1.5 Option enums (clap values + menu labels)

DBOptionwizard.rs:39-79 — clap --db values: sqlite (default), postgres, none.

ValueEndpoint templateNotes
sqlitesqlite://NAME_ENV.sqlite?mode=rwcdefault
postgrespostgres://loco:loco@localhost:5432/NAME_ENVwarns a running Postgres instance is required
noneenable() is false; disables DB, auth, and mailer generation

BackgroundOptionwizard.rs:81-125 — clap --bg values: async (default), queue-redis, queue-postgres, queue-sqlite, blocking.

ValueMenu labelNotes
async”Async (in-process tokio async tasks)“default
queue-redis”Queue: Redis (standalone workers)“warns the selected queue backend must be reachable; generates with the worker_redis feature
queue-postgres”Queue: Postgres (standalone workers)“warns the selected queue backend must be reachable; generates with the worker feature
queue-sqlite”Queue: SQLite (standalone workers)“warns the selected queue backend must be reachable; generates with the worker feature
blocking”Blocking (run tasks in foreground)“warns it blocks requests until the task completes

AssetsOptionwizard.rs:127-162 — clap --assets values: serverside (default), clientside, none.

ValueMenu labelNotes
serverside”Server (configures server-rendered views)“default
clientside”Client (configures assets for frontend serving)“prints follow-up: cd frontend/ && npm install && npm run build
none”None”

OSloco-new/src/lib.rs:41-51 — clap --os values: windows, linux, macos. windows adds a second tool bin target to the generated Cargo.toml (Cargo.toml.t:65-70).

1.6 Derived generation settings

Source: loco-new/src/settings.rs:58-89.

  • DB enabled → Features::default() (loco-rs default features apply to the generated app).
  • DB disabled (Lightweight template, or --db none) → default-features = false, feature names = ["cli"]; if background is queue-redis, "worker_redis" is appended; if background is queue-postgres or queue-sqlite, "worker" is appended.
  • auth and mailer scaffolding are enabled iff DB is enabled.
  • Serverside assets → generated Initializers { view_engine: true }.
  • loco_version_text: normally version = "0.17"; when env var LOCO_DEV_MODE_PATH is set, becomes version = "*", path = "<that path>" — this is how the local framework checkout is dogfooded.
  • Generated app’s own edition is pinned in loco-new/base_template/Cargo.toml.t independent of the loco-rs framework edition.

2. cargo loco — the runtime CLI

Source: src/cli.rs:64-171 (enum Commands).

2.1 Top-level subcommands

SubcommandAliasGated onFlagsPurpose
starts-w/--worker[=tags], -s/--server-and-worker, -a/--all, --scheduler, -b/--binding <ADDR>, -p/--port <PORT>, -n/--no-banner (worker/server_and_worker/all are mutually exclusive)Boot the app in a start mode (cli.rs:66-91)
db#[cfg(feature = "with-db")]see §2.2Database operations (cli.rs:92-97)
routesnonePrint all application endpoints as a tree (cli.rs:98-99)
middleware-c/--configList middlewares (enabled first, then disabled); --config also prints each one’s resolved config (cli.rs:101-105)
taskt[name], key:val... paramsRun a custom task by name, with key:value params (cli.rs:107-114)
jobs#[cfg(feature = "worker")]see §2.3Manage the background jobs queue (cli.rs:115-120)
scheduler-n/--name <NAME>, -t/--tag <TAG>, -c/--config <PATH>, -l/--listRun or inspect the scheduler (cli.rs:121-137)
generateg#[cfg(debug_assertions)]see §2.4Code generation (cli.rs:138-146)
doctor-c/--config, -p/--productionValidate/diagnose the app; --config instead dumps the resolved config + environment and skips checks (cli.rs:147-154, 814-832)
versionnonePrint the app version (cli.rs:155-156)
watchw-w/--worker[=tags], -s/--server-and-worker, --schedulerWraps cargo-watch -s 'cargo loco start ...' (cli.rs:158-170, 838-867); requires cargo-watch installed

Start-mode resolution (cli.rs:736-750): --all or (--server-and-worker and --scheduler) → All; --server-and-worker alone → ServerAndWorker; --worker[=tags] (+ --scheduler) → WorkerAndScheduler / WorkerOnly; --scheduler alone → ServerAndScheduler; none of the above → ServerOnly.

2.2 db subcommands

enum DbCommands, src/cli.rs:483-523 — only present when with-db is enabled.

CommandFlagsPurpose
createCreate the schema/database
migrateApply all pending up-migrations
down[steps] (default 1)Roll back the given number of migrations
resetDrop all tables, then reapply every migration
statusShow migration status
entities— (#[cfg(debug_assertions)])Generate entity .rs files from the current DB schema
truncateTruncate table data without dropping tables
seed-r/--reset, -d/--dump, --dump-tables <csv>, --from <DIR> (default src/fixtures)Seed the DB from files, or dump tables to files (cli.rs:505-520)
schemaDump the database schema

2.3 jobs subcommands

enum JobsCommands, src/cli.rs:598-647 — only present when the worker feature is enabled (worker_redis implies worker).

CommandFlagsPurpose
cancel--name <NAME> (required)Set jobs matching <NAME> to cancelled
tidyDelete jobs that are completed or cancelled
purge--max-age <DAYS> (default 90), --status <csv>, --dump <PATH>Delete old failed/cancelled jobs, optionally dumping them first
dump--status <csv>, -f/--folder <DIR> (default .)Save job details to files
import-f/--file <PATH>Import jobs from a file
requeue--from-age <MINS> (default 0)Move processing jobs older than the given age back to queued

2.4 generate subcommands

enum ComponentArg, src/cli.rs:173-382 — only present in debug builds (#[cfg(debug_assertions)] on Commands::Generate). model/migration/scaffold are additionally gated on #[cfg(feature = "with-db")]. Full field-type syntax is covered in the Generators & field types reference; this table lists CLI shape only.

CommandGatedArgs / flagsNotes
modelwith-dbname, --without-tz, field:type ...Fields support references (e.g. director:references)
migrationwith-dbname, --without-tz, field:type ...Add/remove columns, join tables, empty migrations, references
scaffoldwith-dbname, --without-tz, field:type ..., -k/--kind <KIND>, --htmx, --html, --apiExactly one of --kind/--htmx/--html/--api is required (group scaffold_kind_group); errors otherwise (cli.rs:426-429)
controllername, actions..., -k/--kind <KIND>, --htmx, --html, --apiSame kind-selection rule as scaffold (cli.rs:455-458)
taskname
schedulernoneScaffolds a scheduler config template
workername
mailername
datanameData loader
deploymentkind = docker | nginx (DeploymentKind, cli.rs:554-558)docker inspects static-assets config + frontend/package.json; nginx uses configured host/port
override[template_path], --infoCopies a built-in generator template locally for customization; no path lists all available templates

-k/--kind <KIND> accepts ScaffoldKind: api | html | htmx (loco-gen/src/lib.rs:218-222).


3. cargo loco --help (verified output)

The top-level help, matching enum Commands exactly:

Terminal window
The one-person framework for Rust
Usage: demo_app-cli [OPTIONS] <COMMAND>
Commands:
start Start an app
db Perform DB operations
routes Describe all application endpoints
middleware Describe all application middlewares
task Run a custom task
jobs Managing jobs queue
scheduler Run the scheduler
generate code generation creates a set of files and code templates based on a predefined set of rules
doctor Validate and diagnose configurations
version Display the app version
watch Watch and restart the app
help Print this message or the help of the given subcommand(s)
Options:
-e, --environment <ENVIRONMENT> Specify the environment [default: development]
-h, --help Print help
-V, --version Print version