Guide 12 of 12
Command reference
Every command is spelled the way Rails spells it. bogie help prints the authoritative short version of this page from inside an app.
Bogie, outside an app
| Command | Does |
|---|---|
bogie new NAME [--module=PATH] [--jobs] | Generates a new service in ./NAME. |
bogie version | Prints the version. |
bogie help | This text. |
Bogie, inside an app
Found by its bogie.toml, from any subdirectory.
| Command | Does |
|---|---|
bogie generate GENERATOR NAME, bogie g | Runs a generator: scaffold, model, migration, controller, service, job, authentication. bogie g -h for its own usage. |
bogie destroy GENERATOR NAME, bogie d | Removes what a generator made, registration included. |
bogie doctor | Checks markers, pinned tools and layout files; confirms every controller is constructed and mounted. |
bogie app:update [--pretend] | Moves the app to the installed Bogie's layout: a three-way merge between what the recorded version generated, what this version generates, and the file on disk. Refuses on a dirty git tree; a real overlap leaves conflict markers. |
bogie server, bogie s | Runs the app; migrates at boot. In development it runs under Air: save a file and it rebuilds and restarts. |
bogie worker | Works the job queue (apps with jobs; g job adds them to one that has none). Reloads under Air in development, same as bogie server, to its own binary so the two can run side by side. |
bogie test [PKGS], bogie t | go test -race -cover ./.... |
bogie lint | gofmt check, go vet, golangci-lint. |
bogie ci | Every check, locally, then sign off: bin/ci. |
bogie db:create | Creates the database for the current environment. |
bogie db:drop | Drops it, with --yes added for you. |
bogie db:prepare (db:setup) | Create, migrate, seed. |
bogie db:reset | Drop then prepare. |
bogie db:migrate | Applies pending migrations. |
bogie db:migrate:status | Which migrations have run, which are pending. |
bogie db:migrate:redo | Rolls the last migration back and re-applies it. |
bogie db:rollback | Rolls back the most recent migration. |
bogie db:version | The current schema version. |
bogie db:seed | Applies pending seeds from db/seeds. |
bogie db:seed:rollback | Rolls back the most recent seed. |
bogie credentials:edit [-e ENV] | Opens the encrypted settings for editing. |
bogie credentials:show [-e ENV] | Prints the decrypted file. |
bogie credentials:get [-e ENV] KEY | Prints one value. |
Tasks that destroy pass --yes on your behalf here, the way a laptop command should; the app's own binary in a deployed container keeps asking. bogie db:migrate:up or any other near-miss points at the nearest real task rather than printing the whole usage.
The reload under bogie server and bogie worker is development only: set <NAME>_ENV to anything else and the plain compiled binary runs with no watcher. Air is pinned as a go tool dependency in the app's own go.mod, next to goose, sqlc and credentials, so a fresh clone needs only Go. Its settings are .air.toml; deleting that file turns reload off.
Generators: bogie g / bogie d
| Generator | Arguments | Writes |
|---|---|---|
migration | NAME [field:type ...] | db/migrate/<stamp>_NAME.sql. create_<table>, add_<x>_to_<table> and remove_<x>_from_<table> write their SQL. |
model | NAME [field:type ...] | The migration, db/queries/<table>.sql, app/domain/<name>.go and the store's app/models/<table>.go; then runs sqlc. |
scaffold | NAME [field:type ...] | The model, plus app/views/<table>.go and a <Table>Controller with real handlers over the store, registered. The model is singular, the rest plural, as Rails names them. |
controller | NAME [action ...] | app/controllers/<name>_controller.go, one Rails controller in one file, registered: a field, a wire line and a mount above each marker. Name a resource in the plural. admin/NAME puts it in the admin namespace, app/controllers/admin_controller/, made on first use and registered the same way. |
service | NAME | app/services/<name>/, ctx first, no HTTP, not wired anywhere. |
job | NAME | app/jobs/<name>.go, a River job, registered above bogie:jobs; the first one on an app with no jobs adds them first, merged in like app:update. |
authentication | SHAPE | A middleware on a route group, its config key with a development value written to the credentials, and a WithX group helper on the root Server. SHAPE is secret (the Rails app calls this service), token (bearer JWT a user presents) or api_key (keys for machine clients, with a table and api_keys:create). |
Flags: --pretend reports without writing, --force overwrites a file that differs, --skip-sqlc skips the sqlc run. Attributes are field:type, with :index or :uniq after the type: string text integer bigint boolean datetime uuid jsonb references. A references field names the other model: post:references is post_id.
bogie d GENERATOR NAME removes what the generator of the same name created: its files, and for a controller the three lines that registered it. A namespaced controller's package goes too once it holds no controller; bogie d authentication token also reverses its three lines in config/config.go, leaving the development value harmless in the credentials file.
api_key registers a subcommand on the app's own binary, not on bogie: bogie api_keys:create NAME reaches it through the same proxy rule as db:*, any colon task bogie does not know itself is shorthand for the binary's own, so it runs blog api_keys create NAME.
The app binary itself
A plain Go CLI with spaces, the form bogie accepts too (bogie db prepare works from outside, since the colon tasks above are shorthand for exactly these):
| Command | Does |
|---|---|
blog serve | Runs the HTTP server. |
blog worker | Works the job queue (apps with jobs enabled). |
blog db create | Creates the database this environment points at. |
blog db drop --yes | Drops it; refused in production. |
blog db prepare | Create if needed, migrate, seed. |
blog db seed | Applies pending seeds. |
blog db seed-down --yes | Rolls back the most recent seed. |
blog migrate status | Which migrations have run, which are pending. |
blog migrate version | The current schema version. |
blog migrate up | Applies every pending migration (also done at boot). |
blog migrate down --yes | Rolls back the most recent migration. |
blog migrate down-to N --yes | Rolls back until the schema is at version N (0 = empty). |
These run against whatever database the current <NAME>_ENV selects, including on a deployed host: docker exec <container> blog migrate status.
make targets
| Target | Does |
|---|---|
make help | Every task. |
make up | Start Postgres (Compose) and wait until it is healthy. |
make down | Stop it, keeping the data. |
make reset | Stop it and destroy the data. |
make logs | Tail the containers. |
make psql | Open a shell on the development database. |
make credentials | Edit the encrypted settings (development); ENV=production for its own file and key. |
make build | Compile the binary. |
make server | Run the HTTP server. One boot, no reload; drop to this for a single set of logs. |
make worker | Work the job queue (apps with jobs enabled). One boot, no reload. |
make test | Run the suite with coverage, in the test environment (needs make up). |
make sqlc | Regenerate app/models from db/queries against db/migrate. |
make vet | Stdlib static analysis. |
make fmt | Format. |
make lint | gofmt check + golangci-lint. |
make ci | Every check, locally; green ends with gh signoff (bin/ci). |
make tidy | Prune and verify the module graph. |
make db-create | Create the database, like rails db:create; an existing one is fine. |
make db-drop | Drop the database and every table in it, like rails db:drop. |
make db-prepare | Create if needed, migrate, seed, like rails db:prepare. |
make db-reset | Drop it and rebuild it from the migrations, like rails db:reset. |
make db-migrate | Apply pending migrations (deployed containers do this at boot). |
make db-migrate-down | Roll back the last migration; drops its tables. |
make db-rollback | Rails' name for db-migrate-down; the same task. |
make db-migrate-to V=<version> | Roll back to a version. |
make db-rollback-to | Rails' name for db-migrate-to; the same task. |
make db-migrate-status | Which migrations have run, and which are pending. |
make db-version | The current schema version. |
make db-migrate-redo | Roll the last migration back and re-apply it. |
make db-seed | Apply pending seeds from db/seeds, through the binary. |
make db-seed-down | Roll back the most recent seed. |
make g_migration_<name> | Author a migration (go tool goose). |
make g_seed_<name> | Author a seed (go tool goose). |