10. Config file and environment variable loading #12

Closed
opened 2026-05-20 15:31:34 -06:00 by ppreeper · 0 comments
Owner

Description

Implement configuration loading from env vars and ~/.wkhtmltopdf.json config file.

Tasks

  • Load config from ~/.wkhtmltopdf.json if it exists
  • Supported config keys:
    • chrome_path
    • timeout
    • default_paper_size
    • strict
  • Read env vars:
    • WKHTMLTOPDF_CHROME_PATH
    • WKHTMLTOPDF_TIMEOUT
    • WKHTMLTOPDF_STRICT
  • Priority: CLI flag > env var > config file > hardcoded default
  • Handle malformed config file gracefully (warn, use defaults)

Acceptance Criteria

  • ~/.wkhtmltopdf.json with {"chrome_path": "/usr/bin/chromium"} sets Chrome path
  • WKHTMLTOPDF_TIMEOUT=120 overrides config file timeout
  • --timeout 30 overrides both env var and config file
  • Missing config file → no error, use defaults
  • Malformed JSON in config file → warning on stderr, use defaults

Notes

  • Use json and pathlib from stdlib
  • Config file path: ~/.wkhtmltopdf.json (expand user home)
  • Relates to PRD #2
## Description Implement configuration loading from env vars and `~/.wkhtmltopdf.json` config file. ## Tasks - [ ] Load config from `~/.wkhtmltopdf.json` if it exists - [ ] Supported config keys: - `chrome_path` - `timeout` - `default_paper_size` - `strict` - [ ] Read env vars: - `WKHTMLTOPDF_CHROME_PATH` - `WKHTMLTOPDF_TIMEOUT` - `WKHTMLTOPDF_STRICT` - [ ] Priority: CLI flag > env var > config file > hardcoded default - [ ] Handle malformed config file gracefully (warn, use defaults) ## Acceptance Criteria - `~/.wkhtmltopdf.json` with `{"chrome_path": "/usr/bin/chromium"}` sets Chrome path - `WKHTMLTOPDF_TIMEOUT=120` overrides config file timeout - `--timeout 30` overrides both env var and config file - Missing config file → no error, use defaults - Malformed JSON in config file → warning on stderr, use defaults ## Notes - Use `json` and `pathlib` from stdlib - Config file path: `~/.wkhtmltopdf.json` (expand user home) - Relates to PRD #2
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ppreeper/wkhtmltopdf#12
No description provided.