rewrap body message

This commit is contained in:
David Lord 2025-01-11 16:21:57 -08:00
parent f01a6b0097
commit 63d983afcf
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
2 changed files with 19 additions and 3 deletions

View file

@ -1,6 +1,7 @@
from __future__ import annotations
import dataclasses
import typing as t
from contextlib import chdir
from functools import cached_property
from inspect import isclass
@ -11,6 +12,7 @@ import click
from modify_repos.cmd import echo_cmd
from modify_repos.cmd import run_cmd
from modify_repos.wrap import wrap
@dataclasses.dataclass
@ -91,10 +93,12 @@ class Script:
branch: str
title: str
body: str
target: str = "main"
branch: str
def __init__(self, orgs: list[str], push: bool) -> None:
def __init_subclass__(cls, **kwargs: t.Any) -> None:
super().__init_subclass__(**kwargs)
cls.body = wrap(cls.body, width=72)
def __init__(self, push: bool) -> None:
self.clones_dir: Path = Path("clones")
self.push = push

12
src/modify_repos/wrap.py Normal file
View file

@ -0,0 +1,12 @@
from __future__ import annotations
import textwrap
from inspect import cleandoc
def wrap(text: str, width: int = 80) -> str:
"""Wrap a multi-line, multi-paragraph string."""
return "\n\n".join(
textwrap.fill(p, width=width, tabsize=4, break_long_words=False)
for p in cleandoc(text).split("\n\n")
)