Skip to content

Commit

Permalink
Replace .update-readme-help.sh with Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder authored and asmacdo committed Jun 10, 2024
1 parent 7d0fd7a commit 358c56e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/readme-updated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Update README.md helptext
run: |
./.update-readme-help.sh
./.update-readme-help.py
- name: Ensure no diff
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
hooks:
- id: update-readme
name: Update README with --help output
entry: ./.update-readme-help.sh
entry: ./.update-readme-help.py
language: system
- repo: local
hooks:
Expand Down
18 changes: 18 additions & 0 deletions .update-readme-help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
from pathlib import Path
import re
import subprocess

help_content = subprocess.run(
["duct", "--help"], check=True, text=True, encoding="utf-8", stdout=subprocess.PIPE
).stdout

readme = Path("README.md")
text = readme.read_text(encoding="utf-8")
text = re.sub(
r"(?<=<!--- BEGIN HELP -->\n).*(?=^<!--- END HELP -->)",
help_content,
text,
flags=re.S | re.M,
)
readme.write_text(text, encoding="utf-8")
6 changes: 0 additions & 6 deletions .update-readme-help.sh

This file was deleted.

0 comments on commit 358c56e

Please sign in to comment.