Skip to content

cobo CLI ​

cobo is Runcobo's command-line toolchain for development and deployment. It's a separate binary: your compiled application never loads it.

text
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:

sh
shards install
bin/cobo --help

Or 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 ​

CommandWhat it doesNeeds runcobo.yml
initSet up a project created by crystal init app
routesPrint the application's route table
versionPrint the framework version
devPrepare the database, then run the server and restart it on changes✓
consoleInteractive Crystal console with the app loaded✓
runner FILERun a Crystal script with the app loaded✓
task list / task run NAMERun project tasks defined in runcobo.yml✓
testRun specs against the local test database✓
db ...Local databases, migrations, verification✓
generateGenerate typed SQL query code✓

Commands marked ✓ read the development configuration in runcobo.yml.

cobo init ​

sh
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:

sh
bin/cobo routes
bin/cobo routes --require src/route_loader.cr   # use another entry file
bin/cobo routes --no-color > routes.txt

By 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 ​

sh
bin/cobo dev

Runs the application and restarts it whenever you change it:

  1. Ensures the local development database exists and applies pending migrations (db prepare development).
  2. Runs seed_command, if configured.
  3. Builds src/main.cr and starts it with the development environment:
    • DATABASE_URL pointing at the local development database,
    • each development_environment variable that isn't already set,
    • optionally a generated secret and a public base URL (see configuration).
  4. Watches for changes and rebuilds.
Save a file
src/**/*.cr
Also .jbuilder, .water and shard.lock.
Build
crystal build src/main.cr
The old server keeps running meanwhile.
Swap
Stop the old server gracefully, start the new one.
  • A change that doesn't compile prints the error and leaves the previous server running. Fix it and save again.
  • What's watched: .cr, .jbuilder and .water files under src/, and shard.lock. Files in public/ are read from disk, so changes there need no restart. After changing db/queries/, run cobo generate; the generated code is in src/, so the server restarts.
  • Not applied automatically: new migrations (run bin/cobo db migrate) and changes to runcobo.yml or sqlc.yaml (cobo dev tells you to restart it).
  • If the server exits on its own, cobo dev waits 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 ​

sh
bin/cobo console

Opens 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 ​

sh
bin/cobo runner scripts/backfill.cr -- --dry-run

Compiles 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:

runcobo.yml
yaml
tasks:
  rebuild-search:
    description: Rebuild the local search index
    command: [crystal, run, src/jobs/rebuild_search.cr, --]
sh
bin/cobo task list
bin/cobo task run rebuild-search -- books

Tasks 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 ​

sh
bin/cobo test                 # crystal spec
bin/cobo test --prepare       # create/migrate the test database first
bin/cobo test spec/models -- --verbose

Runs 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).

Released under the MIT License.