1. CLI argument parser and entry point #3

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

Description

Create the main wkhtmltopdf Python 3 entry point with argparse-based CLI parsing.

Tasks

  • Create single-file Python script with #!/usr/bin/env python3 shebang
  • Define all wkhtmltopdf-compatible arguments via argparse:
    • Positional: INPUT (multiple), OUTPUT_FILE
    • --page-size, --page-width, --page-height
    • --orientation, --margin-top, --margin-bottom, --margin-left, --margin-right
    • --dpi, --zoom, --quiet
    • --disable-local-file-access, --enable-local-file-access
    • --javascript-delay, --header-html, --footer-html
    • --cookie-jar, --header-spacing, --header-line
    • --disable-smart-shrinking, --viewport-size
    • --chrome-path, --timeout, --extra-chromium-args
    • --print-media-type
    • --version, --help
  • Print version with --version
  • Print usage with --help
  • Exit code 7 on invalid arguments

Acceptance Criteria

  • wkhtmltopdf --help prints full usage
  • wkhtmltopdf --version prints version string
  • wkhtmltopdf --bad-flag exits with code 7 and error message on stderr
  • wkhtmltopdf with no args exits with code 7 and shows usage
  • All flags parse correctly and store values in a namespace object

Notes

  • Python 3 stdlib only, no pip packages
  • Single file architecture
  • Relates to PRD #2
## Description Create the main `wkhtmltopdf` Python 3 entry point with `argparse`-based CLI parsing. ## Tasks - [ ] Create single-file Python script with `#!/usr/bin/env python3` shebang - [ ] Define all wkhtmltopdf-compatible arguments via `argparse`: - Positional: `INPUT` (multiple), `OUTPUT_FILE` - `--page-size`, `--page-width`, `--page-height` - `--orientation`, `--margin-top`, `--margin-bottom`, `--margin-left`, `--margin-right` - `--dpi`, `--zoom`, `--quiet` - `--disable-local-file-access`, `--enable-local-file-access` - `--javascript-delay`, `--header-html`, `--footer-html` - `--cookie-jar`, `--header-spacing`, `--header-line` - `--disable-smart-shrinking`, `--viewport-size` - `--chrome-path`, `--timeout`, `--extra-chromium-args` - `--print-media-type` - `--version`, `--help` - [ ] Print version with `--version` - [ ] Print usage with `--help` - [ ] Exit code 7 on invalid arguments ## Acceptance Criteria - `wkhtmltopdf --help` prints full usage - `wkhtmltopdf --version` prints version string - `wkhtmltopdf --bad-flag` exits with code 7 and error message on stderr - `wkhtmltopdf` with no args exits with code 7 and shows usage - All flags parse correctly and store values in a namespace object ## Notes - Python 3 stdlib only, no pip packages - Single file architecture - 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#3
No description provided.