Commit Graph

19 Commits

Author SHA1 Message Date
3d06f7dcb0 refactor: pass invocation options down instead of reading a global 2026-09-08 15:43:41 +02:00
056da8b9b2 refactor: build one binary instead of a library and a binary 2026-09-08 15:43:37 +02:00
1bb205bb79 feat: build commands from arguments instead of strings 2026-09-08 11:27:14 +02:00
6e44527a9a feat: deprecate compose subcommand 2026-09-07 13:11:36 +00:00
9d63233d9a feat: detect the django and postgres services
ahab guessed that the django service is called django and the postgres one db,
falling back on AHAB_DJANGO_CONTAINER and AHAB_POSTGRES_CONTAINER. The standard
project layout happens to agree, but nothing enforces it, and a stack naming
them web and database could not use ahab without setting both variables.

One `docker compose config --format json` call, roughly 120ms, resolves the
stack even while it is down, and the services are identified from what they
are rather than what they are called:

- postgres is the service whose image is a postgres flavour, matching postg,
  timescale, pgvector or citus. Nothing else counts.
- django is the service that both builds an image and has
  DJANGO_SETTINGS_MODULE in its environment. A celery worker sharing the same
  build and env_file matches too, so published ports break the tie: the service
  answering requests wins.

Neither guess is allowed to be wrong quietly. No match, or two candidates that
cannot be told apart, is an error naming the services it looked at. There is no
variable to fall back on: both container variables are gone, along with the
guessed defaults they backed up, so an ambiguous stack is fixed in the compose
file rather than worked around per developer.

Every service lookup goes through these rules, so `compose exec` and the whole
django group agree on which container they mean.

POSTGRES_USER and POSTGRES_DB come off the detected service, so dropdb,
createdb, pg_restore and pg_dump stop assuming the role and database are both
literally `db`, falling back to that only when the service declares neither.

Note that env_file entries are merged into a service's environment, so
POSTGRES_* is not safe for identifying the database service: one such line in a
project's .env would make the django service match as well. That is why
identification uses the image and only credentials use the environment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 13:11:35 +00:00
8751c39cce style: run cargo fmt 2026-09-04 11:24:14 +02:00
2000204250 feat: update default service names 2026-02-24 08:52:08 -05:00
36fcc84881 feat: don't read DJANGO_SETTINGS_MODULE 2025-02-12 16:52:50 +01:00
e7308bd5c6 feat: control default services via env vars
Read default postgres compose service name and default django compose
service name from env variables.

AHAB_POSTGRES_CONTAINER - defaults to `appserver`
AHAB_DJANGO_CONATINER - defaults to `postgresdb`

Default values are there for 100% backwards compatibility.
2024-11-27 18:13:12 +01:00
73a0b87c31 feat: swap println for eprintln or debug_eprintln
Unified expected output to always eprintln so outputs can be piped to
other processes. Added debug_eprintln and switched all occurances of
debug_println.
2024-10-25 09:03:49 +02:00
316b37cd05 feat: custom command builder
Implemented custom command builder with nicer api suited for my needs.
Also returned error if there are no containers in
`scripts::postgres::get_containers`.
2023-06-02 17:18:25 +02:00
e3306c494d feat: prepulate command in make-command
Fixed bug where created command file didn't end with `.py` and
prepopulate created file with minimal example of django management command.
2023-06-02 17:16:15 +02:00
5d45eccfef feat: add django test command
Added django's manage.py test command as a shortcut
2023-06-02 17:15:39 +02:00
251826c048 feat: print $DJANGO_SETTINGS_MODULE when it's needed 2023-06-02 17:07:13 +02:00
de5e6b4d10 feat: rename commands and remove aliases in favour of completion
BREAKING CHANGE: changed commands as follows
D -> Docker
Dc -> Compose
Dj -> Django
Pg -> Postgres
2023-05-27 13:30:09 +02:00
423badfe07 fix: all django management command related subcommands
We just called `manage` inside docker instead of
`exec appserver python manage.py`. Now we make assumption that django
app is running in docker-compose in service named `appserver`.

While fixing this bug we also refactored for `shell`, `makemigrations`
and `migrate` to all call `manage` under the hood to avoid repeating code.
2023-05-24 00:21:04 +02:00
286e16e7ce feat: finish django cli and add aliases
Implemented basic wanted functionality for django subcommands.

Added single or two letter aliases for all subsubcommands.
2023-05-23 22:49:18 +02:00
9f3cc86e3f feat: add basic error handling
Add anyhow::Result<()> return signature to all scripts and main.
2023-05-21 23:47:02 +02:00
eb232a93f8 feat: prepare initial cli layout
Made initial command scopes
d -> docker related commands
dc -> docker compose related commands
dj -> django related commands
pg -> postgres related commands
2023-05-21 22:40:34 +02:00