#!/usr/bin/env python3 """Usage: tools/draft-review [--attach [--checked REASON | --checked-file FILE|-]] [--open] [--effort LEVEL] [--model MODEL] Drafts a review of a PR by werkrevisor and Codex with tools/review-report, for a human to check and post; it writes nothing to Gitea. A number means a PR of the default repository; a URL may name any repository on the configured server. The local config ~/.config/werkrevisor/draft-review.toml (or $WERKREVISOR_DRAFT_REVIEW_CONFIG) names the server, the default repository, the werkrevisor config, a secrets file and the names of the tokens; see "Draft review" in the README. It prints the verdict of werkrevisor with its strongest finding, then the paths of report.html and report.md; report.html needs pandoc, and each diagram in it opens on its own with a click. --open opens report.html in the browser of the local config (key browser, default xdg-open), or with --attach the posted comment. With --attach it reviews nothing: it posts the checked draft and its diagrams as a comment of the PR, with the write token; delete the line '> **Draft:** …' first, or give the reason why the remaining points do not hold with --checked or --checked-file (- reads stdin): it replaces that line as "Checked before posting". """ import os import sys # realpath: a link such as ~/bin/ must still find the package of the checkout. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from werkrevisor.draftreview import main # noqa: E402 if __name__ == "__main__": if any(a in ("-h", "--help") for a in sys.argv[1:]) or len(sys.argv) < 2: print(__doc__.strip()) sys.exit(0 if len(sys.argv) > 1 else 2) sys.exit(main(sys.argv[1:]))