cobo CLI
cobo is Runcobo's command-line toolchain for development and deployment. It's a separate binary: your compiled application never loads it.
cobo [--root PATH] COMMAND [arguments...]--root PATH runs a command against another project directory.
Installing
shards install builds it into your project's bin/cobo when Runcobo is installed or upgraded:
shards install
bin/cobo --helpOr install it globally from a framework checkout with make install INSTALL_DIR=..., which also installs a pinned runcobo-dbmate. See Installation.
Commands at a glance
| Command | What it does | Needs runcobo.yml |
|---|---|---|
init | Set up a project created by crystal init app | |
routes | Print the application's route table | |
version | Print the framework version | |
dev | Prepare the database, then run the server and restart it on changes | ✓ |
console | Interactive Crystal console with the app loaded | ✓ |
runner FILE | Run a Crystal script with the app loaded | ✓ |
task list / task run NAME | Run project tasks defined in runcobo.yml | ✓ |
test | Run specs against the local test database | ✓ |
db ... | Local databases, migrations, verification | ✓ |
generate | Generate typed SQL query code | ✓ |
Commands marked ✓ read the development configuration in runcobo.yml.
cobo init
bin/cobo init [--database postgresql|mysql|sqlite|none]Run once, in a project created by crystal init app with Runcobo installed — see Installation. It writes the standard layout with a home endpoint at /, adds the database driver to shard.yml, runs shards install and, with a database, generates the query code (this needs sqlc; if it's missing, install it and run bin/cobo generate).
--database defaults to postgresql; none leaves out sqlc.yaml, db/ and the store. Placeholder files from crystal init are replaced only while unchanged, and any other existing file stops the command before it writes anything.
cobo routes
Compiles your route-registration file and prints every route:
bin/cobo routes
bin/cobo routes --require src/route_loader.cr # use another entry file
bin/cobo routes --no-color > routes.txtBy default it loads src/app.cr. The file must register actions without starting the server — see Project Structure. It doesn't need runcobo.yml or a database.
Colors are on for terminals and off when output is redirected, when NO_COLOR is set, or for TERM=dumb. Force either way with --color / --no-color.
cobo dev
bin/cobo devRuns the application and restarts it whenever you change it:
- Ensures the local development database exists and applies pending migrations (
db prepare development). - Runs
seed_command, if configured. - Builds
src/main.crand starts it with the development environment:DATABASE_URLpointing at the local development database,- each
development_environmentvariable that isn't already set, - optionally a generated secret and a public base URL (see configuration).
- Watches for changes and rebuilds.
src/**/*.crcrystal build src/main.cr- A change that doesn't compile prints the error and leaves the previous server running. Fix it and save again.
- What's watched:
.cr,.jbuilderand.waterfiles undersrc/, andshard.lock. Files inpublic/are read from disk, so changes there need no restart. After changingdb/queries/, runcobo generate; the generated code is insrc/, so the server restarts. - Not applied automatically: new migrations (run
bin/cobo db migrate) and changes toruncobo.ymlorsqlc.yaml(cobo devtells you to restart it). - If the server exits on its own,
cobo devwaits for the next change. - Ctrl-C stops the server gracefully, then
cobo dev.
A project without a sqlc.yaml has no database: cobo dev skips step 1 and sets no DATABASE_URL.
cobo console
bin/cobo consoleOpens the Crystal interpreter (crystal i) with your application entry loaded and the development environment set. Requires a Crystal build that includes the interpreter. The entry is application_entry from runcobo.yml, or src/app.cr if present.
cobo runner
bin/cobo runner scripts/backfill.cr -- --dry-runCompiles and runs a Crystal script after loading your application entry, with the development environment. Arguments after -- are passed to the script. The database is not prepared or seeded.
cobo task
Register reusable commands in runcobo.yml:
tasks:
rebuild-search:
description: Rebuild the local search index
command: [crystal, run, src/jobs/rebuild_search.cr, --]bin/cobo task list
bin/cobo task run rebuild-search -- booksTasks run from the project root with the development environment. Each element of command and each extra argument is passed as a separate argument — no shell is involved.
cobo test
bin/cobo test # crystal spec
bin/cobo test --prepare # create/migrate the test database first
bin/cobo test spec/models -- --verboseRuns crystal spec with DATABASE_URL and TEST_DATABASE_URL set to the project's local test database (left unset in a project without a sqlc.yaml).