- Use
uvdirectly for Python environment and package tasks; do not useuv piporuv venv.
src/fastmail_cli/
__init__.py # Exports main()
__main__.py # python -m fastmail_cli
cli.py # Entry point — promotes FASTMAIL_API_TOKEN env var, calls jmapc.main()
jmapc.py # All CLI commands, argparse setup, JMAP client logic
- Entry point:
fastmail-cli <command> [args](defined in pyproject.toml[project.scripts]) - Single runtime dependency:
jmapc>=0.2.23
uv run fastmail-cli help # list commands
uv run fastmail-cli describe email.query # show command options
uv run fastmail-cli session.get # test auth (needs JMAP_API_TOKEN)Every command returns a JSON envelope:
{
"ok": true,
"command": "email.query",
"args": { "host": "...", "api_token": "**REDACTED**", ... },
"meta": { "timestamp": "...", "account_id": "...", ... },
"data": { ... }
}On failure, "data" is replaced by "error".
- Never log or output API tokens. The
envelope()function redactsapi_tokenfrom output automatically via_sanitize_args(). - Prefer environment variables (
JMAP_API_TOKEN,FASTMAIL_API_TOKEN) over--api-tokenCLI flag — CLI args are visible in process listings. - If adding new sensitive fields to connection options, add the key name to
_REDACTED_KEYSinjmapc.py. - The CLI is read-only by default.
email.draft/email.draft-replycreate drafts but never send.pipeline.runuses an allowlist of safe JMAP methods.
No automated test suite exists yet. Verify changes manually:
uv run fastmail-cli help
uv run fastmail-cli session.get 2>&1 | python -m json.tool