feat(cli): command-line client for administration

- Add parsimony list, member, held, archive and queue subcommands over the REST API
- Read the token only from PARSIMONY_API_TOKEN; take the URL from --url or PARSIMONY_URL
- Print tables by default and JSON with --json
- Add member import from a file or stdin, reporting failing lines and exiting non-zero
- Require --yes for destructive commands
- Add parsimony serve; keep the old -config invocation working
- Run the CLI inside the container in the end-to-end test
- Test every command against the real API handler; mutation checks over the CLI
This commit is contained in:
tgiachi 2026-11-09 16:57:25 +01:00
commit 2d8b0ccce6

View file

@ -17,6 +17,7 @@ A modern, single-binary mailing list manager: an evolution of Mailman.
Public pages hide email addresses.
- Per-recipient one-click unsubscribe links (RFC 8058) with signed tokens.
- SQLite storage, one YAML config file.
- Command-line client for administration and scripts (`parsimony list|member|held|archive|queue`).
- Admin REST API under `/api/v1` (see `docs/openapi.yaml`).
- Admin web UI (Vite, React, shadcn/ui) served by the API listener at `/`: lists, settings,
members, held queue and archive.
@ -25,7 +26,7 @@ A modern, single-binary mailing list manager: an evolution of Mailman.
```
cp parsimony.example.yaml parsimony.yaml
PARSIMONY_API_TOKEN=<token> go run ./cmd/parsimony -config parsimony.yaml
PARSIMONY_API_TOKEN=<token> go run ./cmd/parsimony serve -config parsimony.yaml
```
The API is disabled when `PARSIMONY_API_TOKEN` is not set.
@ -45,6 +46,31 @@ the unsubscribe links in every message use it. Keep the `api` listener private.
curl -H "Authorization: Bearer $PARSIMONY_API_TOKEN" -d '{"name":"dev","domain":"example.org","title":"Dev"}' localhost:8080/api/v1/lists
```
## Command line
The same binary is an administration client. It talks to the REST API, so it works against a local or remote daemon.
```
export PARSIMONY_API_TOKEN=... # the token is never a flag
export PARSIMONY_URL=http://127.0.0.1:8080 # default; --url overrides
parsimony list add dev@example.org --title "Developers"
parsimony list set dev@example.org --post moderated --archive public
parsimony member add dev@example.org alice@example.com --name Alice
parsimony member import dev@example.org subscribers.txt # "email[,name]" per line, "-" reads stdin
parsimony held ls dev@example.org
parsimony held approve 12
parsimony archive ls dev@example.org --q "deploy"
parsimony queue ls
parsimony --json list ls # JSON for scripts
parsimony help
```
`<list>` is an address or a numeric id. Destructive commands (`list rm`, `archive rm`) need `--yes`.
Exit status: 0 success, 1 failure (including lines that failed in `member import`), 2 usage error.
`parsimony serve -config FILE` runs the daemon; the old `parsimony -config FILE` form still works.
In the container: `docker exec parsimony /parsimony list ls`.
## Docker
The image runs as an unprivileged user (uid 65532) and works with a read-only root filesystem.